• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query Help

#9
[eluser]vitoco[/eluser]
First, if you use INNER JOIN you are telling to the db explicitly that must be al least 1 resume, 1 video and 1 pdf related to the user, to return a row. Also, the number of rows returned will be all rows in table * all rows in all the other tables. So try with this query to check number of items per table, associated with the user and start from there.

Code:
SELECT
  user.*  ,
  COUNT( user_resume.user_resume_user ) AS num_resumes ,
  COUNT( user_video.user_video_user  ) AS num_videos ,
  COUNT( user_pdf.user_pdf_user ) AS num_pdfs
FROM
  user
LEFT JOIN
  user_resume
ON
  user_id = user_resume_user
LEFT JOIN
  user_video
ON
  user_id = user_video_user
LEFT JOIN
  user_pdf
ON
  user_id = user_pdf_user
WHERE
  user_id = ‘1’
GROUP BY
  user_id

Saludos


Messages In This Thread
Query Help - by El Forum - 06-20-2012, 03:34 PM
Query Help - by El Forum - 06-20-2012, 03:58 PM
Query Help - by El Forum - 06-20-2012, 04:01 PM
Query Help - by El Forum - 06-20-2012, 04:03 PM
Query Help - by El Forum - 06-20-2012, 04:06 PM
Query Help - by El Forum - 06-20-2012, 05:15 PM
Query Help - by El Forum - 06-20-2012, 05:23 PM
Query Help - by El Forum - 06-20-2012, 06:18 PM
Query Help - by El Forum - 06-20-2012, 06:33 PM
Query Help - by El Forum - 06-20-2012, 07:49 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.