A have a table so :
id | name | idparent | info 1 | AA | | x 2 | BB | | 3 | CC | | x 4 | DD | 1 | 5 | EE | 1 | 6 | FF | 2 | 7 | GG | 2 | 8 | HH | 3 | 8 | HH | 4
and what i want to do is done like this with mySQL/PHP :
SELECT id FROM table WHERE info LIKE 'x'
and in PHP
for i in each id result of the first request : SELECT id, name FROM table where idparent = i ORDER BY RAND() LIMIT 1; endFor
for instance, the result could be :
4 |DD 8 |HH
and because of the RAND(), the result could be too :
5 |EE 8 |HH
but it is not so beautiful, is there a possibility to do this in just one request ?
I have tried several idea but without success, i don't enumerate here, in order not to pollute the comprehension my subject :)
Thank's in advance for your answer