gausie Posted March 29, 2008 Share Posted March 29, 2008 SELECT E1.name AS name, E1.id AS id, E2.name AS parentname FROM categories AS E1 INNER JOIN categories AS E2 ON E1.parent_id = E2.id WHERE E2.parent_id = '0' ORDER BY E1.amount ASC So I want to limit the results from E1 (for each E2 record) to 5 only How can I do that? Gausie Quote Link to comment https://forums.phpfreaks.com/topic/98489-limit-on-a-join-cant-work-it-out/ Share on other sites More sharing options...
cooldude832 Posted March 29, 2008 Share Posted March 29, 2008 you might need to query inside for select count(E1.id) from `E1` where E1.id=E2.id and use that as your Limit Quote Link to comment https://forums.phpfreaks.com/topic/98489-limit-on-a-join-cant-work-it-out/#findComment-504032 Share on other sites More sharing options...
fenway Posted March 30, 2008 Share Posted March 30, 2008 You can't limit on a join... you'd have to create a derived table with this artificial limit, then join it back. Quote Link to comment https://forums.phpfreaks.com/topic/98489-limit-on-a-join-cant-work-it-out/#findComment-504442 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.