Re: Lower record
Re: Lower record
От:
"Abe" <abe@fish.tm>
Дата:
Thanks Len, works a treat... Abe ----- Original Message ----- From: "Len Morgan" To: "Abe" ; Cc: "Christopher Kings-Lynne" Sent: Sunday, December 24, 2000 1:36 AM Subject: Re: [GENERAL] Lower record > >... I also cant use the following: > > > >$sql = "select threadid, commentid, name, detail from comments where > >commentid < '$commentid' and threadid='$threadid'"; > > > > > > because it gets the lowest value comment whereas what I want is the > highest > >value comment but lower that $commentid (so basically the one immediately > >below this one). > > > How about: > > select threadid, commentid, name detail from comments where > comentid < '$commentid' and threadid='$threadid' > ORDER BY commentid DESC LIMIT 1 ; > > The ORDER BY ... DESC will put the highest commentid first and the LIMIT 1 > will only return one record. > > > Len Morgan > >
Re: Lower record
От:
"Len Morgan" <len-morgan@crcom.net>
Дата:
>... I also cant use the following: > >$sql = "select threadid, commentid, name, detail from comments where >commentid < '$commentid' and threadid='$threadid'"; > > > because it gets the lowest value comment whereas what I want is the highest >value comment but lower that $commentid (so basically the one immediately >below this one). How about: select threadid, commentid, name detail from comments where comentid < '$commentid' and threadid='$threadid' ORDER BY commentid DESC LIMIT 1 ; The ORDER BY ... DESC will put the highest commentid first and the LIMIT 1 will only return one record. Len Morgan