wiqi iam
wiqi iam

Reputation: 43

Why my JOIN is showing double results?

So this is what my query looks like, but its producing double results. I am newbie to SQL.

SELECT * FROM tbl_projects p, tbl_issues i WHERE p.admin_id = 3 

Upvotes: 1

Views: 58

Answers (2)

HoneyBadger
HoneyBadger

Reputation: 15150

You're joining in an old style, without join conditions, so you get a cartesian product. Please use explicit join syntax:

SELECT   * -- It is recommended to explicitly select the attributes you need
FROM     tbl_projects p
JOIN     tbl_issues i -- I assumed inner join
      ON p.id = i.project_id -- You'll have to figure out the conditions yourself
WHERE    p.admin_id = 3 

Upvotes: 3

TheSultanOfCode
TheSultanOfCode

Reputation: 1

This is not a JOIN query, and you're not using the table "tbl_issues" anywhere

Upvotes: 0

Related Questions