richrock Posted April 21, 2010 Share Posted April 21, 2010 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 https://forums.phpfreaks.com/topic/199280-trying-to-count-i-with-left-joins-in-statement/ Share on other sites More sharing options...
Ken2k7 Posted April 21, 2010 Share Posted April 21, 2010 It's hard to help when I don't know what you want the SQL to do. Link to comment https://forums.phpfreaks.com/topic/199280-trying-to-count-i-with-left-joins-in-statement/#findComment-1045968 Share on other sites More sharing options...
richrock Posted April 21, 2010 Author Share Posted April 21, 2010 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. Link to comment https://forums.phpfreaks.com/topic/199280-trying-to-count-i-with-left-joins-in-statement/#findComment-1045973 Share on other sites More sharing options...
richrock Posted April 21, 2010 Author Share Posted April 21, 2010 My bad - I don't know the difference between local and remote databases : Link to comment https://forums.phpfreaks.com/topic/199280-trying-to-count-i-with-left-joins-in-statement/#findComment-1045983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.