Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outer join

Status
Not open for further replies.

pat26

Technical User
Nov 23, 2003
3
0
0
US
When I run the query it doesn't include all records from the tblVehicleSegment only those which are mached with tblTargetVehicle. What do I have to do to get all records from tblVehicleSegment? Thanks for you help.


SELECT tblVehicleSegment.SEGMENT, tblVehicleSegment.VEHICLE_CODE, tblVehicleSegment.QUALITY_GATE_F, tblVehicleSegment.QUALITY_GATE_E, tblVehicleSegment.QUALITY_GATE_D, tblVehicleSegment.QUALITY_GATE_C, tblTargetVehicle.REALIZED_QUALITY_GATE_F, tblTargetVehicle.REALIZED_QUALITY_GATE_E, tblTargetVehicle.REALIZED_QUALITY_GATE_D, tblTargetVehicle.REALIZED_QUALITY_GATE_C, tblTargetVehicle.GCS_ID
FROM tblTargetVehicle RIGHT JOIN tblVehicleSegment ON tblTargetVehicle.VEHICLE_CODE = tblVehicleSegment.VEHICLE_CODE
WHERE (((tblTargetVehicle.GCS_ID)=4));
 
You are setting a criteria on a field in tblTargetVehicle. In order for there to be a value there, the tables have to have matching keys (Vehicle_CODE). If you want all records from tblVehicleSegment but just those that are GCS_ID=4 from tblTargetVehicle, you need this in your WHERE:

tblTargetVehicle.GCS_ID=4 OR tblTargetVehicle.GCS_ID Is Null
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top