LIMIT amount of rows fetched by JOIN
- by user892134
How do i LIMIT the child rows fetched to only 5?
Here is the SQLfiddle http://sqlfiddle.com/#!2/bd96a/2. Right now it fetches all rows with parentid='4' and parentid='14'. It should only fetch 5 of each parentid. Assuming i have hundreds of rows, it should only fetch a max of 5 for each parentid.
"SELECT child.* FROM mytable as parent
LEFT JOIN mytable as child on child.parentid=parent.id
WHERE parent.pageid IN ( 1, 2) AND parent.submittype='1'
ORDER BY child.id ASC";
How do i solve this?