日期:2014-05-16  浏览次数:20520 次

不同数据库SQL语句的差别

1,系统时间

Oracle:SYSDATE

SQLSever:getdate()

Access:date()? 或者 now()

2,查询前n条记录

Oracel: Select * From (Select……) where rownum<=10 ?? ((Select……)是要真正查询的语句)

SQLServer:Select * From…………Top 10

MySql:Select * From tablename Limit 10

3, 随即抽取

MySql:?FROM `table` AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `table`)-(SELECT MIN(id) FROM `table`))+(SELECT MIN(id) FROM `table`)) AS id) AS t2?WHERE t1.id >= t2.id?ORDER BY t1.id LIMIT 1;