imarockstar Posted May 22, 2009 Share Posted May 22, 2009 I am currently joining these 2 tables -> <?php $sql="SELECT * FROM todo INNER JOIN users ON todo.userid = users.id WHERE todo.userid = '{$_SESSION['id']}' " or die(mysql_error()); $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <div class='boxd'><a href=''><? echo $rows['title']; ?></a></div> <div class='boxb'><span class="submitted">submitted by</span> <? echo $rows['name']; ?></div> <div class='boxb''><span class="submitted">complete by</span> <? echo $rows['deadline']; ?></div> <br class="clear"> <? } ?> Works fine .. but i need to add one more table to the join .. .which is a table called BANDS and i need to join is based on the USERID .. so the join would look like this 'users.id = bands.userid' but I am not sure how to include that into the query ... any help would be rad !!! Quote Link to comment https://forums.phpfreaks.com/topic/159302-table-joining-question/ Share on other sites More sharing options...
corbin Posted May 22, 2009 Share Posted May 22, 2009 SELECT blah FROM bleh JOIN bleck JOIN blerh; Is the basic skeleton of what you're asking. Quote Link to comment https://forums.phpfreaks.com/topic/159302-table-joining-question/#findComment-840167 Share on other sites More sharing options...
imarockstar Posted May 22, 2009 Author Share Posted May 22, 2009 what about the 'INNER JOIN users ON' do i need to do the 'ON' again ? Quote Link to comment https://forums.phpfreaks.com/topic/159302-table-joining-question/#findComment-840178 Share on other sites More sharing options...
fenway Posted May 22, 2009 Share Posted May 22, 2009 Yes... one join, one join condition. Quote Link to comment https://forums.phpfreaks.com/topic/159302-table-joining-question/#findComment-840187 Share on other sites More sharing options...
imarockstar Posted May 22, 2009 Author Share Posted May 22, 2009 i did this .... $sql="SELECT * FROM todo INNER JOIN users ON todo.userid = users.id INNER JOIN bands ON todo.userid = bands.userid WHERE todo.userid = '{$_SESSION['id']}' " and it like doubled all my output lol .. oh ya sorry ... mysql v4.5 . i believe Quote Link to comment https://forums.phpfreaks.com/topic/159302-table-joining-question/#findComment-840194 Share on other sites More sharing options...
fenway Posted June 1, 2009 Share Posted June 1, 2009 There's nothing wrong with that... not sure what you mean by doubled -- you're asking for *. Quote Link to comment https://forums.phpfreaks.com/topic/159302-table-joining-question/#findComment-846827 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.