View Full Version : Novice Select SQL Statement


dungstar
04-03-2002, 03:19 PM
This should be a simple SQL statement; I've done it before but just can't figure it out now.

I have a LabSample table. The lab sample has couple fields that are foreign keys TechID (from Technician table) and ProjectID (from Project table).

Not all records in the LabSample table contain a TechID or ProjectID.
Under the Technician table, the attributes are TechID (PKey), TechName.
Under the Project table, the attributes are ProjID (PKey) and PI (investigator).

I am trying to create a query, that shows all LabSample attributes and if a TechID exist, also show TechName, and if ProjID exist, also show the PI.

Thanks for your help!

Pat Hartman
04-03-2002, 07:53 PM
You need to use Left or Right Joins rather than Inner Joins in situations where the foreign key values may be null. Open the query in QBE view and right click on the center of each join line. Choose the second or third option depending on which table is on the left.