mysql - select top 与 limit的区别在哪里?
迷茫
迷茫 2017-04-17 11:45:59
0
2
733

比如,我们想查询结果集的最面的两条信息,比如persion表的头两条记录:



SELECT TOP 2 * FROM Persons

也可以使用limit:

select * from   Persons limit 0,2

请问这两个有什么区别,谁更好一点呢????????

我擦!!
MYSQL没有SELECT TOP的语法!!!
白问了,奶奶的

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
Peter_Zhu

This is how it is used in different databases:
1. Select top sql usage supported in access/ms sql server;
2. The supported sql usage in mysql/oracle is select...limit;
There is no difference between the two in terms of usage. It’s just that the application platform is different.

迷茫
mysql> SELECT TOP 2 * FROM ac_article_img;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual       that corresponds to your MySQL server version for the right syntax to use 
    near '2 * FROM ac_article_img' at line 1

Which version of Mysql are you using? It seems that this query is not supported after 5.0.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!