Hello experts I want to fetch only first row from the table using query of mysql. How can I do that? Can anyone advice that?
You need to have a unique ID for every row first. Assuming you have an int field called "id" with auto increment this would show the first row: SELECT * FROM table ORDER BY id LIMIT 1; If you want to show the last row: SELECT * FROM table ORDER BY id DESC LIMIT 1;
You can achieve this using LIMIT keyword. The other variations of LIMIT.. Use this function to page through your data. If you have a result that returns 26 rows, you could divide it on 3 pages ( giving max 10 rows per page ). SELECT * FROM `tablename` LIMIT 0,10; --Page1 SELECT * FROM `tablename` LIMIT 10,10; --Page2 SELECT * FROM `tablename` LIMIT 20,-1; --Page3 -1 refers to till the end