Jump to content

[SOLVED] INNER JOIN


SchweppesAle

Recommended Posts

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?  :P

Link to comment
https://forums.phpfreaks.com/topic/176717-solved-inner-join/
Share on other sites

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

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.