Reputation: 2505
I have a table name : allocate_rooms has id, room_id, startTime, endTime.
now I have to find the Query where result should be return zero Means user will give input as room id and startTime and endTime and it should check whether in that room_id there is any startTime and endTime
Eg: if someone give room name as sunday and startTime as 12:00:00 and endTime as 12:30:00 it will check whether in sunday there is any startTime and endTime But if he give room name as Monday user can save the input.
SELECT id FROM allocate_rooms
where startTime='12:00:00' and endTime=' 12:30:00' AND day_id = 'sunday'
I have written the Query but it's not working properly. How do I write the exact query?
Upvotes: 0
Views: 114
Reputation: 393
From what I understand you need 0
or 1
as output, try the below query
SELECT ifnull (id, 0, 1)
FROM allocate_rooms
WHERE startTime='12:00:00' or endTime=' 12:30:00'
AND day_id = 'sunday'
Upvotes: 0