Forums

This topic is locked

select all except top record

Posted 31 Mar 2003 10:01:12
1
has voted
31 Mar 2003 10:01:12 Julio Taylor posted:
hi

i'm making a news page, i want a recordset to return all the records, <b>except</b> the newest one, since i am using the newest record in a separate recordset on the same page. how can i do this?

i have tried stuff like 'select * from table where id &lt;&gt; max(id) but it just doesn't work....

any ideas?

thanks!

------------------------
Julio

PHP | MySQL | DWMX | ColdFusion

ICQ: 19735247

Replies

Replied 31 Mar 2003 10:07:08
31 Mar 2003 10:07:08 Vince Baker replied:
You could nest the sql:

select *
from table
where id &lt;&gt; (select max(id) from table)

That should work

Regards
Vince

Visit my home: www.chez-vince.com

VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 31 Mar 2003 11:11:11
31 Mar 2003 11:11:11 Julio Taylor replied:
hey vince...

it's giving me an SQL syntax error.... <img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle> <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>

i'll keep playing around see if i can find out the solution...

------------------------
Julio

PHP | MySQL | DWMX | ColdFusion

ICQ: 19735247
Replied 01 Apr 2003 16:21:47
01 Apr 2003 16:21:47 Brent Colflesh replied:
Dear Julio,
Unless you have MySQL 4.x, Vince's code won't work - it depends on a subselect.

You could do an initial query for MAX(ID), stuff it in a variable, then have the subsequent query check against it.

Regards,
Brent

Reply to this topic