bobtutos Posted May 6, 2013 Share Posted May 6, 2013 (edited) I would like to ask for an assistance on how to select all rows but not the last row using PHP/MSQL database . Your help is much appreciated. Thanks. Edited May 6, 2013 by bobtutos Link to comment Share on other sites More sharing options...
justsomeguy Posted May 6, 2013 Share Posted May 6, 2013 You'll need to get the row count with one query, and use the row count in the next select query with a limit clause. Link to comment Share on other sites More sharing options...
niche Posted May 6, 2013 Share Posted May 6, 2013 You may need the ORDER BY keywords too. http://www.w3schools.com/sql/sql_orderby.asp Link to comment Share on other sites More sharing options...
davej Posted May 7, 2013 Share Posted May 7, 2013 ...how to select all rows but not the last row using PHP/MSQL database . What is different about the "last" row? Can you simply avoid it with a condition? Link to comment Share on other sites More sharing options...
bobtutos Posted May 8, 2013 Author Share Posted May 8, 2013 Thanks for the hints but as I am real new on Mysql/sql I do not how to go throw this, please if possible give me the code so that i can learn from that. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 8, 2013 Share Posted May 8, 2013 You get the count: SELECT COUNT(*) AS num FROM table And then you use that count in the next query: SELECT * FROM table LIMIT 0, {$count - 1} You need to use PHP to fill in $count - 1, because the numbers in a limit clause need to be constants, you can't do it with 1 query. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now