cristalmolix Posted March 5, 2010 Share Posted March 5, 2010 hi guys im joing 2 tables onto a users and then joining another table onto them tables and then i want all the users and then a count of all there observations and a count of all the uploaded images for that observation. SELECT u.username AS Username, u.id AS 'User ID', u.title AS 'Title', u.forename AS 'First Name', u.surname AS 'Last Name', u.address1 AS 'Address Line 1', u.address2 AS 'Address Line 2', u.town AS 'Town/City', c.title AS 'County', u.postcode AS 'Postcode', u.age AS 'Age', u.youth_name AS 'School Name', count(i.observation_id) AS 'Number Of Uploads', count(o.id) AS 'Number Of Identifications', CASE WHEN u.ispot = 1 THEN 'No' ELSE 'Yes' END AS 'Mailing List Subscribed (Yes\No)', u.email AS 'Email Address' FROM user u LEFT JOIN (observation o, county c, image i) ON (u.id = o.user_id AND u.county_id = c.id AND i.observation_id = o.id) WHERE 1=1 {$from_to_filter} {$subscribed_filter} GROUP BY o.user_id its just not working out in order to count i have to use group by and that makes the 1300 users turn into 230 for some reason ??????????? any help suggestions would be very much appreciated thanks Quote Link to comment https://forums.phpfreaks.com/topic/194273-joined-table-counting-and-all-of-first-tabel-return-records-sql-help/ Share on other sites More sharing options...
fenway Posted March 13, 2010 Share Posted March 13, 2010 Sorry, I don't follow. Quote Link to comment https://forums.phpfreaks.com/topic/194273-joined-table-counting-and-all-of-first-tabel-return-records-sql-help/#findComment-1025706 Share on other sites More sharing options...
cristalmolix Posted March 15, 2010 Author Share Posted March 15, 2010 thanks fen, i ended up doing it in arrays, the sql is too much Quote Link to comment https://forums.phpfreaks.com/topic/194273-joined-table-counting-and-all-of-first-tabel-return-records-sql-help/#findComment-1026707 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.