Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how to check available cleaner

how to check available cleaner

Scheduled Pinned Locked Moved Database
questiondatabasecomhelptutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    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? http://www.JassimRahma.com[^] http://www.rmc.bh[^] http://www.ume.bh[^] http://www.xoompage.com[^] http://www.volow.com[^] http://www.curesoftware.com[^]

    Technology News @ www.JassimRahma.com

    D Richard DeemingR 2 Replies Last reply
    0
    • J Jassim Rahma

      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? http://www.JassimRahma.com[^] http://www.rmc.bh[^] http://www.ume.bh[^] http://www.xoompage.com[^] http://www.volow.com[^] http://www.curesoftware.com[^]

      Technology News @ www.JassimRahma.com

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      Seems like you need to check the end time ...

      AND end_time BETWEEN param_start_time AND param_end_time)

      Maybe the check for the end time needs to be

      OR end_time BETWEEN param_start_time AND param_end_time

      J 1 Reply Last reply
      0
      • D David Mujica

        Seems like you need to check the end time ...

        AND end_time BETWEEN param_start_time AND param_end_time)

        Maybe the check for the end time needs to be

        OR end_time BETWEEN param_start_time AND param_end_time

        J Offline
        J Offline
        Jassim Rahma
        wrote on last edited by
        #3

        BETWEEN always uses AND not OR

        Technology News @ www.JassimRahma.com

        D 1 Reply Last reply
        0
        • J Jassim Rahma

          BETWEEN always uses AND not OR

          Technology News @ www.JassimRahma.com

          D Offline
          D Offline
          David Mujica
          wrote on last edited by
          #4

          What I meant to say is the following ...

          OR end_time BETWEEN param_start_time AND param_end_time

          Notice where I put the "OR"

          J 1 Reply Last reply
          0
          • J Jassim Rahma

            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? http://www.JassimRahma.com[^] http://www.rmc.bh[^] http://www.ume.bh[^] http://www.xoompage.com[^] http://www.volow.com[^] http://www.curesoftware.com[^]

            Technology News @ www.JassimRahma.com

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #5

            You've posted a list of six links in the bottom of your question, none of which relate to your question, and which don't appear to be part of your signature. I understand the desire to show off your work, but is this really the best way to do it?


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            1 Reply Last reply
            0
            • D David Mujica

              What I meant to say is the following ...

              OR end_time BETWEEN param_start_time AND param_end_time

              Notice where I put the "OR"

              J Offline
              J Offline
              Jassim Rahma
              wrote on last edited by
              #6

              I tried this but didn't work too!

              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 OR end_time BETWEEN param_start_time AND param_end_time) AND is_active = TRUE ORDER BY cleaner_name;

              Please help...

              Technology News @ www.JassimRahma.com

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups