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 * 
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 *"

Answers


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 * ...


Need Your Help

Whats possible in a for loop

c# java c loops for-loop

So today I went to an interview and one of the questions was the following (C# context).

twitter bootstrap typeahead ajax example

jquery twitter-bootstrap jquery-autocomplete jquery-ui-autocomplete typeahead.js

I'm trying to find a working example of the twitter bootstrap typeahead element that will make an ajax call to populate it's dropdown.