Re: joins issues again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steven Macintyre wrote:
 Hi all,

I have the following SQL statement;

SELECT count( salesID ) AS count, branch_name, company_name, branch.branchID
	FROM sales
	LEFT JOIN IGuser ON sales.IGuid = IGuser.IGuid
	LEFT JOIN branch ON IGuser.branchID = branch.branchID
	LEFT JOIN company ON branch.companyID = '{$companyID}'
	WHERE maincompanyid = '{$mcid}'
	GROUP BY branch.branchID
	ORDER BY branch_name ASC

I know that your DB might be able to figure out what is and is not ambiguous, but, since we don't have the table structure to look at and compare. How about using table.column naming for us.

Doing a desc `table_name` for us on each table would help also.


However, i do not want those join records to be appended, only to return the count of records from sales.

Can someone assist me with this? I have tried differance variants of joins and none of the results are correct.

Sales tbl doesnt have the companyID, nor does IGuser

Regards,

Steven




--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux