I agree it's probably not possible with one query, unless you have 4.1
for subqueries.
One thought is to use variables:

SELECT @m:=max(ID) from A;
SELECT @m1:=max(ID) from A WHERE ID < @m;
 SELECT fields FROM A 
 LEFT JOIN B ON B.aID = A.ID WHERE A.ID in ( @m, @m1) ORDER BY A.ID
DESC;



> -----Original Message-----
> From: Cybot [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 12, 2003 1:05 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Limiting left joins
> 
> 
> > I have two tables, A and B, where the entries in B are 
> connected to A 
> > through a left join. Thus there may be several entries in B 
> for each 
> > post in A.
> > 
> > Now I would like to select the two latest posts in A and all the 
> > corresponding posts in B. I tried something like SELECT 
> fields FROM A 
> > LEFT JOIN B ON B.aID = A.ID ORDER BY A.ID DESC LIMIT 2, but 
> that only 
> > got the latest two entries in B and the last entry in A (which 
> > corresponds to them both). Then I tried using some GROUP BY 
> > statements, to no avail. Please help!
> 
> you have to use two querys or subselects
> 
> -- 
> Sebastian Mendel
> 
www.sebastianmendel.de
www.tekkno4u.de
www.nofetish.com


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to