Jump to content

help with query ... join issue


imarockstar

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

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.