Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

FN-FORUM: MySQL Query Problem

date posted 13th March 2006 11:25

Hello,

I have an application and am joining 4 tables in a query and I need to
return a COUNT of one column from the 4th table instead of the actual data.
Theoretically, a COUNT should return zero when there is no data, but for
some reason it returns no data in my query. When there are matching entries
in the 4th table it happily returns the data. I'm sure this is just a case
of me not seeing the obvious in the SQL, so if somebody could offer a fresh
pair of eyes and some pointers I'd appreciate it.

Here's the MySQL statement:

$sql = 'SELECT u.*, a.*, p.*, COUNT(o.oCustomerID) AS numOrders
FROM cUsers AS u, oOrders AS o
LEFT JOIN cAuthority AS a ON u.uSecurityLevel =
a.aID
LEFT JOIN uProfiles AS p ON u.uID = p.pUserID
WHERE a.aLevel "Customer" AND u.uID =
o.oCustomerID
GROUP BY o.oCustomerID
ORDER BY p.pLastName' ;

It's the COUNT(o.oCustomerID) that's causing me grief. I take it out and I
get rows returned. I add some data into the oOrders table and I get rows
returned. I take out the data in oOrders and I get nothing.

And on a Monday too!

Thanks
Edward



Messages by Day
March 31st 2006
March 30th 2006
March 29th 2006
March 28th 2006
March 27th 2006
March 26th 2006
March 25th 2006
March 24th 2006
March 23rd 2006
March 22nd 2006
March 21st 2006
March 20th 2006
March 19th 2006
March 18th 2006
March 17th 2006
March 16th 2006
March 15th 2006
March 14th 2006
March 13th 2006
March 12th 2006
March 11th 2006
March 10th 2006
March 9th 2006
March 8th 2006
March 7th 2006
March 6th 2006
March 5th 2006
March 4th 2006
March 3rd 2006
March 2nd 2006
March 1st 2006


Messages by Month
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000