Problem whith query in query

From: Date: Mon, 18 Nov 2002 03:57:09 +0000
Subject: Problem whith query in query
Groups: php.general 
Request: Send a blank email to php-general+get-124863@lists.php.net to get a copy of this message
Hello, I need some help whith a mysql-query. Can anyone help? Is there a good newsgroup for mysql? Identifiseringid is the primary key of the table identifisering and is autoincrement. There is also a coloumn named dprosjekt in identifisering and some other coloumns. dprosjekt has the same value for several tuples. For each unike dprosjekt I want to print the record where identifiseringid is max. I tought this would work, but it won't: SELECT * FROM identifisering as i WHERE i.identifiseringid=(SELECT MAX(ii.identifiseringid) FROM identifisering as ii GROUP BY dprosjekt); also tried: SELECT * FROM identifisering as i WHERE i.identifiseringid IN (SELECT MAX(ii.identifiseringid) FROM identifisering as ii GROUP BY dprosjekt); When I split the query they work: SELECT * FROM identifisering as i WHERE i.identifiseringid='123'; SELECT MAX(ii.identifiseringid) FROM identifisering as ii GROUP BY dprosjekt; Thanks, Lars

« previous php.general (#124863) next »