SchweppesAle Posted October 6, 2009 Share Posted October 6, 2009 Hi, I'm trying to learn how to use proper INNER JOIN Syntax so I can stop using so many WHERE(s). The following code is returning false though, so I think I must have screwed up the syntax $banner_table = $prefix.'banner'; $client_table = $prefix.'faclient'; $Query = "SELECT $banner_table.startdate , $banner_table.enddate , $banner_table.clicks , $banner_table.maxclicks , $banner_table.clientid , $client_table.clientid AS CID , $client_table.contactname , $client_table.contactemail FROM $banner_table, $client_table INNER JOIN $client_table ON $client_table.clientid = $banner_table.clientid"; /* $Mail_Sent = new Mail($Query);*/ $result = mysql_query($Query); echo '<pre>'; echo print_r($Query); echo '</pre>'; echo var_dump($result); output: SELECT jos_banner.startdate , jos_banner.enddate , jos_banner.clicks , jos_banner.maxclicks , jos_banner.clientid , jos_faclient.clientid AS CID , jos_faclient.contactname , jos_faclient.contactemail FROM jos_banner, jos_faclient INNER JOIN jos_faclient ON jos_faclient.clientid = jos_banner.clientid1 bool(false) is it obvious? Link to comment https://forums.phpfreaks.com/topic/176717-solved-inner-join/ Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 Try... $Query = "SELECT $banner_table.startdate , $banner_table.enddate , $banner_table.clicks , $banner_table.maxclicks , $banner_table.clientid , $client_table.clientid AS CID , $client_table.contactname , $client_table.contactemail FROM $banner_table INNER JOIN $client_table ON $client_table.clientid = $banner_table.clientid"; Link to comment https://forums.phpfreaks.com/topic/176717-solved-inner-join/#findComment-931687 Share on other sites More sharing options...
SchweppesAle Posted October 6, 2009 Author Share Posted October 6, 2009 wow, that worked... I don't get it though, I thought you need to specify which tables you're retrieving the columns from. Link to comment https://forums.phpfreaks.com/topic/176717-solved-inner-join/#findComment-931690 Share on other sites More sharing options...
SchweppesAle Posted October 6, 2009 Author Share Posted October 6, 2009 *rolls shoulder* oh well, thanks man. lol Link to comment https://forums.phpfreaks.com/topic/176717-solved-inner-join/#findComment-931695 Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 By JOIN'ing the second table you now have brought it into 'scope' with regards to selecting columns from it. Link to comment https://forums.phpfreaks.com/topic/176717-solved-inner-join/#findComment-931703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.