I have in database:
User:
id | name
1 | one
2 | two
3 | three
4 | four
5 | five
House:
id | name
1 | London
2 | Barcelona
UserHouse:
id_user | id_house
1 | 1
2 | 2
4 | 1
How can i use in SQL query IF and ISSET?
SELECT * from User
I would like receive:
users:
name | has_house
1 | yes
2 | yes
3 | no
4 | yes
5 | no
I must start my query with SELECT * from User. I can’t star from House or UserHouse.
Is possible? If yes, how?
I can use also DOCTRINE and Symfony.
Try using
LEFT JOIN