How can I fetch first 5 records in mysql? I am trying to use top 5 clause but unable to get it. Please help me with it
Data has no inherent order in a database, so by itself 'first 5 records' means nothing. So, you have to define what 'first 5 records' means by using the 'ORDER BY' keyword (http://www.1keydata.com/sql/sql-limit.html) then you use the 'LIMIT' keyword to (http://www.1keydata.com/sql/sql-limit.html) limit the number of records returned.
Can you post your table structure? As plog put it, first 5 is very ambiguous. It could mean the most recent 5, the first 5 rows in the table, etc.
Agree with 'Plog', you have to use 'Order by' keyword. Example : Select * from users order by join_date desc limit 5
select * from table name Order by asc LIMIT 5 mysql does't support top 5 keyword. It is use in sql and oracle.