Subject | Help with SQL query |
---|---|
Author | bill_zwirs |
Post date | 2005-02-06T09:50:33Z |
Would appreciate help with an SQL query (Firebird database using
Delphi 5 Pro and IBX components).
The two tables I am querying are Contractors and Cont_Jobs and the
result that I want is a list of contractors who would be available
between the two passed parameters 'jobstart' and 'jobend' (ie.
those that are not already allocated a job in the period between
'jobstart' and 'jobend'). ContractorID is primary key in
Contractors table and foreign key in Cont_Jobs table. JobStart is a
TimeStamp field in the Cont_Jobs table - so the parameters I am
passing are DateTime.
select C.Firstname || ' ' || C.Lastname as Contractor, C.ContractorID
from Contractors C left join Cont_Jobs J on C.ContractorID =
J.ContractorID
where J.JobStart not between :jobstart and :jobend
This query doesn't give me a result at all and if I change
the 'where' clause to 'and', making the last line part of the 'from'
clause, then I get a list of all contractors
including those that have a job allocated between the passed
parameters.
The Contractor table contains names etc of the contractors and the
Cont_Job table contains details of jobs allocated to contractors.
This is driving me crazy. What am I missing. Any help would be
appreciated.
thanks in advance
Bill
Delphi 5 Pro and IBX components).
The two tables I am querying are Contractors and Cont_Jobs and the
result that I want is a list of contractors who would be available
between the two passed parameters 'jobstart' and 'jobend' (ie.
those that are not already allocated a job in the period between
'jobstart' and 'jobend'). ContractorID is primary key in
Contractors table and foreign key in Cont_Jobs table. JobStart is a
TimeStamp field in the Cont_Jobs table - so the parameters I am
passing are DateTime.
select C.Firstname || ' ' || C.Lastname as Contractor, C.ContractorID
from Contractors C left join Cont_Jobs J on C.ContractorID =
J.ContractorID
where J.JobStart not between :jobstart and :jobend
This query doesn't give me a result at all and if I change
the 'where' clause to 'and', making the last line part of the 'from'
clause, then I get a list of all contractors
including those that have a job allocated between the passed
parameters.
The Contractor table contains names etc of the contractors and the
Cont_Job table contains details of jobs allocated to contractors.
This is driving me crazy. What am I missing. Any help would be
appreciated.
thanks in advance
Bill