imarockstar Posted September 17, 2009 Share Posted September 17, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/174627-help-with-query-join-issue/ Share on other sites More sharing options...
kickstart Posted September 17, 2009 Share Posted September 17, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/174627-help-with-query-join-issue/#findComment-920305 Share on other sites More sharing options...
imarockstar Posted September 17, 2009 Author Share Posted September 17, 2009 oh ok .. let me give that a try .. thanks man .. b Quote Link to comment https://forums.phpfreaks.com/topic/174627-help-with-query-join-issue/#findComment-920309 Share on other sites More sharing options...
imarockstar Posted September 18, 2009 Author Share Posted September 18, 2009 oh ya duh .. i forgot to mention that i need to retrieve all the info in the table as well .. so i can display it .. thanks b Quote Link to comment https://forums.phpfreaks.com/topic/174627-help-with-query-join-issue/#findComment-920774 Share on other sites More sharing options...
kickstart Posted September 18, 2009 Share Posted September 18, 2009 Hi Just add them in, but specify the columns you want (even if all of them, just in case someone adds a massive image as a column on one table which you do not want in this script) and use alias names if needs be. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/174627-help-with-query-join-issue/#findComment-920819 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.