Jump to content

table joining question


imarockstar

Recommended Posts

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 !!!

 

Link to comment
https://forums.phpfreaks.com/topic/159302-table-joining-question/
Share on other sites

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

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.