Reputation: 1366
I have table A and B. A has one column a_id. B has two columns b_id and a_id (a_id is foreign key here). A-B is 1-n relationship. Want to SELECT a_id of A with LIMIT, at the same time return all b_id that associated with those selected a_id. Without LIMIT it can be done by
SELECT A.a_id, B.b_id FROM A LEFT JOIN B ON A.a_id = B.a_id;
But how can I LIMIT only A without LIMIT the final result.
Upvotes: 0
Views: 522
Reputation: 1109
How about
SELECT * FROM
(SELECT A.a_id FROM A LIMIT 10) AS ALIMIT
LEFT JOIN B ON ALIMIT.a_id = B.a_id;
Upvotes: 1