dwex Posted July 30, 2010 Share Posted July 30, 2010 I have 3 tables. 1. drama table dramaID drama_title 1 drama1 2. drama_genre table drama_genreID dramaID genreID 1 1 2 2 1 1 3. genre table genreID genre 1 comedy 2 romance I wanna display in a way that for example, Title genre drama1 comedy || romance I tried "Select * from "SELECT * FROM drama , genre , drama_genre WHERE drama.dramaID = drama_genre.dramaID AND genre.genreID = drama_genre.genreID"; <?php while($row=mysqli_fetch_assoc($result)){ echo $row ['drama_title']; echo $row['genre'] ; } mysqli_close($link); ?> Result was .. Title genre drama1 comedy drama1 romance Please Help >.< Quote Link to comment https://forums.phpfreaks.com/topic/209383-multiple-table-query-please-take-a-look/ Share on other sites More sharing options...
wildteen88 Posted July 30, 2010 Share Posted July 30, 2010 SQL Join SELECT d.drama_title, GROUP_CONCAT(g.genre separator ' || ') AS genres FROM drama_genre dg LEFT JOIN drama d ON dg.dramaID = d.dramaID LEFT JOIN genre g ON dg.genreID = g.genreID GROUP BY d.drama_title Quote Link to comment https://forums.phpfreaks.com/topic/209383-multiple-table-query-please-take-a-look/#findComment-1093359 Share on other sites More sharing options...
dwex Posted August 4, 2010 Author Share Posted August 4, 2010 thx man! Quote Link to comment https://forums.phpfreaks.com/topic/209383-multiple-table-query-please-take-a-look/#findComment-1095038 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.