Php sql sorgusu döngü nasıl önlenir?

0 Cevap php

En iyi bu durumda bir seçme yapmak için bir yol, ve php iç içe geçmiş sorguları kullanmadan çıkış bu nedir? Ben tek bir sorgu ile bunu yapmak için tercih ediyorum.

Benim tablo şöyle:

table1

id | items |
---|-------|
1  | item1 |
2  | item2 |
3  | item3 |
.. | ..    |


table2

id | itemid | comment  |
---|--------|----------|
1  | 1      | comment1 |
2  | 1      | comment2 |
3  | 2      | comment3 |
4  | 3      | comment4 |
5  | 3      | comment5 |
6  | 3      | comment6 |
.. | ..     | ..       |

Bu benim aradığım çıktı.

item1
comment1
comment2

item2
comment3

item3
comment4
comment5
comment6

Şimdiden teşekkürler

0 Cevap