Select first 10 distinct rows in mysql
Is there any way in MySQL to get the first 10 distinct rows of a table.
i.e. Something like...
SELECT TOP 10 distinct *开发者_Go百科
FROM people
WHERE names='SMITH'
ORDER BY names asc
However this method doesn't actually work, because it gives the error: "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
If you need add group by clause. If you search Smith you would have to sort on something else.
Try this SELECT DISTINCT 10 * ...
精彩评论