Reputation: 765
I have some database like this.
date name closed
2017-01-10 room1 0
2017-01-11 room2 1
2017-01-12 room3 0
I want to get all the records if in column closed all the value is 0. If any one value is 1, I don't want to show all the record.
How can I make some query to do that ?
This is what I have so far:
SELECT * FROM availability a
WHERE a.closed = 0
Thank you.
Upvotes: 0
Views: 42
Reputation: 166
This will show all the records in the table, only if all records in availability have the closed value = 0
select *
from availability
where 0 = (
select sum( a.closed )
from availability a
)
Upvotes: 3