Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

how to check available cleaner

$
0
0

Hi,

I have a job_orders table in my database with cleaner_id, job_order_date, start_time and end_time.

I am inserting job orders in the database.

I would like to check before inserting for available staff

I tried the following:

SELECT cleaner_id, cleaner_name FROM cleaners WHERE cleaner_id NOT IN (SELECT cleaner_id FROM job_orders WHERE job_order_date = param_job_order_date AND start_time BETWEEN param_start_time AND param_end_time) AND is_active = TRUE ORDER BY cleaner_name;

then added a record with start_time = 10:00 and end_time = 13:00

when I tried to run the code again with start_time = 11:00 and end_time = 13:00 it works fine

but when I try start_time = 11:00 and end_time = 14:00 it will not determine that staff is already booked for 10:00 to 13:00.

how can I fix this please?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>