LIMIT in a subselect, but without using subselects




I'm using mysql v 4.0.something (so no subselects :( )

I have a table of shoppingcarts, and a table of cartitems. cartitems
have the cartuid of the shoppingcart they're in. Pretty simple, right?

if I do:

SELECT * from shoppingcarts left join cartitems on cartitems.cartuid=
shoppingcarts.uid LIMIT 50,10;

The LIMIT clause will be limiting the number of "rows" I get back in
the results (of course). What I *want* it to limit is the number of
"shoppingcarts" I get back. So I can make a tool that shows 10
shopping carts (with items in them) per page.

If I could do subselects, this is what the query would look like:

select * from shoppingcarts left join cartitems on cartitems.cartuid=
shoppingcarts.uid where shoppingcarts.uid in (select uid from
shoppingcarts order by created desc LIMIT 50,10);

(obviously that's untested since I can't do subselects on my mysql).

How can I do that with a left join instead? thanks

.



Relevant Pages

  • Re: Joining and pagination
    ... select * from shoppingcarts left join cartitems on cartitems.cartuid= ... shoppingcarts.uid where cartitems.uid in (select uid from shoppingcarts ... How would I do that without subselects? ...
    (comp.databases)
  • Joining and pagination
    ... I have a table of shoppingcarts, and a table of cartitems. ... have the cartuid of the shoppingcart they're in. ... Prev by Date: ...
    (comp.databases)
  • Re: Joining and pagination
    ... MrKrinkle wrote: ... I have a table of shoppingcarts, and a table of cartitems. ... have the cartuid of the shoppingcart they're in. ... What I *want* it to limit is the number of "shoppingcarts" I get back. ...
    (comp.databases)
  • Re: Joining and pagination
    ... aarg make that: ... select * from shoppingcarts left join cartitems on cartitems.cartuid= ... shoppingcarts.uid where shoppingcarts.uid in (select uid from ...
    (comp.databases)