OceanDesigner
Programmer
Last week I got terrific help with a query. I would like to add one more criterion to the query, but it is just too complicated for me. The new criterion itsself is somewhat complicated so I will ask about the simplest form first.
Here are the original tables
tblService:
ServiceID Desc
a first
b second
c third
d fourth
tblBoat:
ID Boat ServiceID Status
1 101 a ok
2 101 b pending
3 102 a ok
4 103 d ok
Here is the query and result I have now thanks to r937:
Results for Boat 101:
ServiceID Status
a ok
b pending
c NULL
d NULL
Now I am adding a new table. The table tells me which boats the service bulletin affects.
tblAffects:
ServiceID Criteria
a BETWEEN 100 AND 102
b BETWEEN 100 AND 106
c BETWEEN 104 AND 108
d BETWEEN 104 AND 108
So now I need to edit the query above so that it only returns bulletins that affect the selected boat
New Results for Boat 101:
ServiceID Status
a ok
b pending
The only way I can think to do this is to generate a separate query that returns valid ServiceID's and use that in a where clause. Can I do this with JOINs?
Jeff
Here are the original tables
tblService:
ServiceID Desc
a first
b second
c third
d fourth
tblBoat:
ID Boat ServiceID Status
1 101 a ok
2 101 b pending
3 102 a ok
4 103 d ok
Here is the query and result I have now thanks to r937:
Code:
select S.ServiceID
, B.Status
from tblService S
left outer
join tblBoat B
on S.ServiceID
= B.ServiceID
and B.BoatID = 101
Results for Boat 101:
ServiceID Status
a ok
b pending
c NULL
d NULL
Now I am adding a new table. The table tells me which boats the service bulletin affects.
tblAffects:
ServiceID Criteria
a BETWEEN 100 AND 102
b BETWEEN 100 AND 106
c BETWEEN 104 AND 108
d BETWEEN 104 AND 108
So now I need to edit the query above so that it only returns bulletins that affect the selected boat
New Results for Boat 101:
ServiceID Status
a ok
b pending
The only way I can think to do this is to generate a separate query that returns valid ServiceID's and use that in a where clause. Can I do this with JOINs?
Jeff