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... ?

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.