Jump to content

Trying to count (i.*).... with LEFT JOINS in statement ?


richrock

Recommended Posts

Hi,

 

I've got a query that's throwing up an error, really stuck why.  It read right to me, but it's just not working.

 

Its attempting to count all fields from a table with left joins as criteria for filtering....

 

SELECT COUNT(i.*) AS value FROM jos_yearbook_instruments i
            LEFT JOIN jos_yearbook_country co ON i.country_id = co.id
					LEFT JOIN jos_yearbook_city ci ON i.city_id = ci.id
					LEFT JOIN jos_yearbook_circa c ON i.circa_id = c.id
					LEFT JOIN jos_yearbook_makers m ON m.id = i.maker_id
					LEFT JOIN jos_yearbook_auctioneers a ON a.id = i.auctioneer_id

 

Can anyone help?  I tried i.id but that gave me an incorrect total... ?

Gah!  Me and my hurried typing - its simply supposed to count the total number of entries in a table, based on the left joins matching up (city is present in table, etc)

 

phpmyadmin tells me when I count(*) I have ~25,500 results (rounding), yet running this in joomla tells me I have #77,000, quite a discrepancy.  And phpmyadmin is correct.  :confused:

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.