dachshund Posted May 1, 2009 Share Posted May 1, 2009 <?php $today = date('Y-m-d'); $sql="SELECT * FROM interviews ORDER BY id DESC"; $result=mysql_query($sql); ?> hello everyone, just wondering if anyone knows how to uninclude an id? from this code i want id no1 to be unincluded because i already have more code to place it at the top of the page, and dont want it represented twice. any help would be much appreciated. thanks Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/ Share on other sites More sharing options...
jackpf Posted May 1, 2009 Share Posted May 1, 2009 WHERE `ID`!=1 Something liek that. Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823410 Share on other sites More sharing options...
dachshund Posted May 1, 2009 Author Share Posted May 1, 2009 could you show me where to put that in the code? sorry i couldn't do it. reasonably new to this. Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823414 Share on other sites More sharing options...
lonewolf217 Posted May 1, 2009 Share Posted May 1, 2009 $sql="SELECT * FROM interviews WHERE ID != 1 ORDER BY id DESC"; Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823419 Share on other sites More sharing options...
dachshund Posted May 1, 2009 Author Share Posted May 1, 2009 ok that works, but i stupidly asked the wrong question. i need the most recent id to be removed, whatever number that might be at the time. Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823423 Share on other sites More sharing options...
dachshund Posted May 1, 2009 Author Share Posted May 1, 2009 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823447 Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 SELECT e.* FROM interviews e, interviews k WHERE e.id < k.id Something like that? Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823455 Share on other sites More sharing options...
jackpf Posted May 1, 2009 Share Posted May 1, 2009 $last = mysql_insert_id(); $query = "SELECT * FROM table WHERE ID != $last"; Something like that I think. Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823553 Share on other sites More sharing options...
fenway Posted May 1, 2009 Share Posted May 1, 2009 Always the most recent? Then you can skip the "first" one with LIMIT and an offset. Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823554 Share on other sites More sharing options...
dachshund Posted May 1, 2009 Author Share Posted May 1, 2009 hmm still havent got it. how would i skip the first one with a limit and an offset? Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823586 Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 Hmm.. thought it would work. SELECT * FROM interviews e INNER JOIN interviews k ON e.id < k.id Per fenway, it would be like LIMIT 1,999999999999 or some really big number at the end. Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823588 Share on other sites More sharing options...
dachshund Posted May 1, 2009 Author Share Posted May 1, 2009 hmm when i try that it just comes up with 2 of the one i dont want (the latest id) at the bottom :-\ Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823594 Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 Oh, try using DISTINCT. SELECT DISTINCT e.* FROM interviews e, interviews k WHERE e.id < k.id Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-823614 Share on other sites More sharing options...
dachshund Posted May 2, 2009 Author Share Posted May 2, 2009 ok great that worked, thanks for everyones help. no doubt ill be back on here with more Q's soon. Quote Link to comment https://forums.phpfreaks.com/topic/156401-solved-uninclude-an-id/#findComment-824183 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.