canalcasting Posted November 19, 2007 Share Posted November 19, 2007 Hello everyone. I just know a little about this and I just can't get further on this issue. I am trying to display all data from mysql except the last one ? is it possible ? Not sure if I explain it clearly but for example, I have 10 entries in a table... If I add one, then it would be 11 total. The Query would only show the id from 1 to 10.... and vice versa... if there is 45 entry, then the query would show id 1 to 44. Every time I would add one entry, the query would only show all Except the last one entered.. Someone told me about this addtion : where id>max(`id`) order by id but I only get syntax error .... this is what I have now : "SELECT * FROM dailynews ORDER BY id DESC where id>max(`id`) " I have looked everywhere but I just don't get it.... Would appreciate any advice , help..... Thanks so much Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 19, 2007 Share Posted November 19, 2007 EDIT - On second thought, that query won't work... Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 19, 2007 Share Posted November 19, 2007 Not sure if the syntax is right on the second query, but this is how I would do it... should give you an idea... <?php $query = "SELECT `id` FROM `dailynews`"; $result = mysql_query($query); $rows = mysql_num_rows($result); $rows2 = $rows - 1; $query2 = "SELECT * from `dailynews` ORDER BY `id` DESC LIMIT 1, $rows2"; // ... ?> Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 19, 2007 Share Posted November 19, 2007 I had similar type of problem like yours and had got this code (yeah... from here ) SELECT * FROM `dailynews` WHERE id < (SELECT MAX(id) FROM dailynews); This will work definitely but a mod here said it is not reliable ??? confused till now http://www.phpfreaks.com/forums/index.php/topic,165518.msg728414.html#msg728414 Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 19, 2007 Share Posted November 19, 2007 it looks like u doing some pagintion type deal so look up those tutorial Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.