在mysql中select前10个不同的行
MySQL有没有办法获得表的前10个不同的行。
即某事像…
SELECT TOP 10 distinct * FROM people WHERE names='SMITH' ORDER BY names asc
然而,这个方法实际上并不工作,因为它给出了错误:“Syntax Error。Missing operator in query expression distinct *”
SELECT DISTINCT * FROM people WHERE names = 'Smith' ORDER BY names LIMIT 10
SELECT * FROM people WHERE names ='SMITH' ORDER BY names asc limit 10
如果你需要添加分组的子句。 如果你search史密斯,你将不得不sorting其他东西。
试试这个SELECT DISTINCT 10 * ...
SELECT DISTINCT TOP 10 * FROM people WHERE names='SMITH' ORDER BY names ASC LIMIT 10