Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    4

    Unanswered: Noob SQL question, but we all gotta start somewhere!

    Hey guys,

    I need some help with a SQL question.

    Basically I have the following tables{

    Driver{
    DriverID (pk)
    DriverName
    }

    NonDriverAvailabilityInstance{
    DriverID (pk)
    Date(pk)
    }

    Job{
    JobID (pk)
    DriverID
    Cost
    Length
    From
    Too
    Date
    }

    Now assuming this was a working DB, what would be an SQL query could I use to query the DB to tell me which Driver is free on a specific date. The plan is to inject (with php) into the query the date that is required. The query will then display all the drivers who could possibly be used.

    I have tried the following :
    Code:
    SELECT Driver.DriverName
    FROM (Driver INNER JOIN Job ON Driver.DriverID = Job.DriverID) INNER JOIN NonDriverAvailabilityInstance ON Driver.DriverID = NonDriverAvailabilityInstance.DriverID
    WHERE (((Job.Time)<>#5/22/2011#)) OR (((NonDriverAvailabilityInstance.Time)<>#5/22/2011#));
    But it doesn't work and is displaying driver 1's name 3 times. Which obviously is a null result.

    The background to this question is that the taxi company website to which all the drivers have jobs or instances when there busy. Just need to check the DB to tell me which drivers are free on the specific date injected by the php. Then later will come the functionality of updating the Job table with information as to new Jobs.

    This isn't a "homework" assignment. Amazingly its for a real project i'm doing for someone, but being a noob web designer I've never had to use a DB in my coding, so i'm new to it all!

    Please help

    Cheers Lecsiy
    Last edited by lecsiy; 05-15-11 at 19:42.

  2. #2
    Join Date
    Oct 2009
    Posts
    340
    since this is an Access forum; use Access' query design grid

    if you have Driver's & "OffDate" columns so that this results correctly when run

    then your criteria is:

    <JobStartDate AND >JobEndDate

    if that returns the correct records when run, then put the the query back into design mode and option for sql view - - which will give you the syntax to plug into your code.

    Hope this helps.
    www CahabaData com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •