SQL JOIN help

Sean Wilson snw at paradise.net.nz
Mon May 30 16:28:17 CDT 2005


Does anyone have a recommendation of a listserve or newsgroup dealing with 
general SQL questions? I've googled and haven't come up with anything that 
looks promising.

The following is what I'm needing help with at the moment (and it isn't 
Valentina specific, though I'm using VStudio connected to an ODBC source):
I have 4 tables - customers, locations, tasks and taskTypes - that I need 
to query. I have a taskTypeName that I need to filter the results on. The 
following works, but doesn't filter on the taskTypes.taskTypeName

SELECT
tblCustomers.custLName, tblCustomers.custFName, tblLocations.locRoad, 
tblTasks.taskArea, tblTasks.taskOrderDate, tblTasks.taskReadyDate
FROM
tblCustomers, tblLocations, tblTasks
WHERE
tblTasks.taskLocID = tblLocations.locID AND tblLocations.locCustId = 
tblCustomers.custID AND IsNull(tblTasks.taskCompleteDate)

How do I join/sub-select the tasks table on the taskType table so that if I 
have a specific taskTypeName (for example "ploughing") I can select records 
of that type AND maintain the joins I already have. The tasks table has a 
taskTTypID foreign key field that points to the taskType table. I suspect 
my existing query could be re-worded as a JOIN, but I'm not sure what that 
might look like and even why/whether a JOIN might be more efficient than 
the existing WHERE based on foreign keys

Thanks for any advice or pointers,
-Sean.




More information about the Valentina mailing list