scarhand Posted November 5, 2010 Share Posted November 5, 2010 theres gotta be a way so that this only uses 1 query....im assuming using a join and a group by heres my current code: $sql = mysql_query("select * from `databases` where `id` in (select `id_database` from `categories`)"); while ($row = mysql_fetch_assoc($sql)) { echo $row['name'] . '<br />'; $sql_c = mysql_query("select * from `categories` where `id_database`='" . $row['id'] . "'"); while ($row_c = mysql_fetch_assoc($sql_c)) { echo $row_c['title'] . '<br />'; } } Quote Link to comment https://forums.phpfreaks.com/topic/217817-help-with-a-join-and-group/ Share on other sites More sharing options...
fenway Posted November 7, 2010 Share Posted November 7, 2010 select * from `databases` inner join `categories` on `databases`.`id`= `categories`.`id_database` Quote Link to comment https://forums.phpfreaks.com/topic/217817-help-with-a-join-and-group/#findComment-1131384 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.