Jump to content

Recommended Posts

 

i have this JOIN query ..

 

$sql="SELECT * FROM tourdates INNER JOIN bands ON tourdates.bandid = bands.id WHERE tourdates.id = '$id' && tourdates.userid = ". $_SESSION['id'];

 

it works great  the only prob is that when I try and display the ID from my TOURDATES table .. its displaying th ID gtom the BANDS table ..

 

how can i display both IDs ?

 

thanks

b

 

 

php v 5

mysql v 4

 

 

Link to comment
https://forums.phpfreaks.com/topic/174627-help-with-query-join-issue/
Share on other sites

Hi

 

Best not to use SELECT *

 

Specify the columns you are interested in, and if a column name is shared between 2 tables then give them an alias.

 

$sql="SELECT tourdates.id AS tourdateId, bands AS bandId FROM tourdates INNER JOIN bands ON tourdates.bandid = bands.id WHERE tourdates.id = '$id' && tourdates.userid = ". $_SESSION['id'];

 

All the best

 

Keith

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.