Jump to content
MakeWebGames

Problem with query


Recommended Posts

SELECT
    COUNT(JR_refID) AS rankCount,
    J_id AS id,
    J_name AS name,
    J_desc AS `desc`
  FROM
    jobs
  JOIN jobRanks ON(J_id =JR_refID)
  GROUP BY J_id
  ORDER BY J_id ASC

 

My problem is if theres a job with no Ranks, it is not included in in the results. What am I missing? Thanks in advance!!

I know @Magictallguy got an answer here.

Link to comment
Share on other sites

You need to use LEFT JOIN then this should solve your issue 

SELECT
        COUNT(JR_refID) AS rankCount,
        J_id AS id,
        J_name AS name,
        J_desc AS `desc`   
    FROM
        jobs   
    LEFT JOIN
        jobRanks 
            ON(
                J_id =JR_refID
            )   
    GROUP BY
        J_id   
    ORDER BY
        J_id ASC
 
Edited by AdamHull
  • Like 1
Link to comment
Share on other sites

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.   Paste as plain text instead

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