Re: Problem whith query in query

From: Date: Wed, 20 Nov 2002 17:51:27 +0000
Subject: Re: Problem whith query in query
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-125282@lists.php.net to get a copy of this message
Quoting Ernest E Vogelsinger <ernest@vogelsinger.at>: > 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. Sorry, that's what I was trying to decipher... The '=' combined with the use of MAX led me to believe the desired recordset size was ONE in the sub query. -- Ryan T. Gallagher ryan@studiesabroad.com International Studies Abroad http://www.studiesabroad.com (512)480-8522

« previous php.general (#125282) next »