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 *"
To select first 10 elements from a database using SQL ORDER BY clause with LIMIT 10. Insert some records in the table using insert command. Display all records from the table using select statement. Here is the alternate query to select first 10 elements.
To get unique or distinct values of a column in MySQL Table, use the following SQL Query. SELECT DISTINCT(column_name) FROM your_table_name; You can select distinct values for one or more columns.
To do so, select Query -> Include Actual Query Plan from the menu before executing the query. The “Stream Aggregate” icon is for the DISTINCT operation and “Top” for the TOP 10 one. It may seem somewhat counterintuitive to see DISTINCT listed first within the SELECT statement.
SELECT DISTINCT * FROM people WHERE names = 'Smith' ORDER BY names LIMIT 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With