Re: Problem whith query in query

From: Date: Wed, 20 Nov 2002 17:44:48 +0000
Subject: Re: Problem whith query in query
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-125281@lists.php.net to get a copy of this message
At 18:29 20.11.2002, Ryan Gallagher said: --------------------[snip]-------------------- >SELECT * FROM identifisering as i >WHERE i.identifiseringid = ( > SELECT MAX(ii.identifiseringid) AS maxIdentifiseringid > FROM identifisering as ii > ) >GROUP BY dprosjekt > >Now that I look at it, your GROUP BY was definitely out of place, since >dprosjekt no doubt is a col being returned from the SELECT * of the main >query. --------------------[snip]-------------------- No, it wasn't. You need the GROUP BY in the subquery to retrieve the max(id) for any distinct dprosjekt. If you have it like you did the subquery would simply return a single result, the max(id) of all records. Your version simply functions as an "order by" which is useless here since only a single record will be returned. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#125281) next »