Kevin Walter
Kevin Walter

Reputation: 7166

Relational query return null values

I have a question. In my database there are 2 tables. For example say: Calendar table

Signup table

User table

And i want to see what users are coming to a specific event. So i have the query:

SELECT *
FROM user u, signup s
WHERE u.uid = s.user_id
AND s.event = 1

But this shows me all the users who have actually created a record in the database. I also want to see the users who don't have a record in the signup table. How can i achieve this?

Kind regards,

Upvotes: 0

Views: 18

Answers (1)

juergen d
juergen d

Reputation: 204746

Don't use the old implicit join syntax any more. Use explicit joins. In your case - a left join

SELECT *
FROM user u
LEFT JOIN signup s ON u.uid = s.user_id
                  AND s.event = 1

Upvotes: 1

Related Questions