Re: Problem whith query in query
| From: | OrangeHairedBoy | Date: | Mon, 18 Nov 2002 05:07:49 +0000 |
| Subject: | Re: Problem whith query in query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-124869@lists.php.net to get a copy of this message | ||
MySQL doesn't support queries inside queries.
I think it's on their TODO list...
SELECT * FROM identifisering as i
> WHERE i.identifiseringid=(SELECT MAX(ii.identifiseringid)
> FROM identifisering as ii
> GROUP BY dprosjekt);
"Lars Espelid" <lars_espelid@hotmail.com> wrote in message
news:20021118035730.61650.qmail@pb1.pair.com...
> 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
>
>
>