Is there a way to fetch the first entry of a table in database using SQL query?

后端 未结 2 1935
北海茫月
北海茫月 2021-01-13 20:30

I have a database table which stores names of people, i want to fetch the first entry of my database table. Is it possible using SQL query?

相关标签:
2条回答
  • 2021-01-13 21:10

    Use the following:

    SELECT * FROM names LIMIT 1
    

    And if you want the first sorted entry, then use the following:

    SELECT n.* FROM names n ORDER BY n.last_name ASC, n.first_name ASC LIMIT 1
    
    0 讨论(0)
  • 2021-01-13 21:30

    you can use select first(column_name) from table_name order by primary_id first().is an aggregate function available for mssql you can also go for 'top' in mssql

    0 讨论(0)
提交回复
热议问题