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

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.