I am having difficulties wrapping my brain around this one. Still a newb when it comes to SQL. I created a table called "SURG_TYPE" that only has 2 fields (Surgery_Num, Surg_Type).
I have populated this table with the Surgery Numbers but now I need to populate the "Surg_Type" from a separate table (tblMeasurement).
The issue I am having is that there is a one to many relationship (Surgery_Type.Surgery_Num=tblMeasurement.srgID).
So I first need to check to see if the "Surg_Type" field is NULL, and if so, then add tblMeasurement.MeasurementType to the field.
Then the following criteria (sorry for the coding):
If Surg_Type in ('FinalRefraction', 'Refraction') then tblMeasurement.MeasurementType
else
If Surg_Type = 'LRI' and tblMeasurement.MeasurementType = "TORIC" then 'LRI+TORIC'
else
If Surg_Type = 'TORIC' and tblMeasurement.MeasurementType = "LRI" then 'LRI+TORIC'
So you can see sometimes you only need to evaulate the table that you are inserting into and sometime you need to evaluate the source and destination tables.
I am confused and I hope I didn't confuse you to. I tried to use CASE as well, but I think I am digging myself a deeper hole.
I know this is simple to a lot of you and can really use some help.
Thanks in advance
I have populated this table with the Surgery Numbers but now I need to populate the "Surg_Type" from a separate table (tblMeasurement).
The issue I am having is that there is a one to many relationship (Surgery_Type.Surgery_Num=tblMeasurement.srgID).
So I first need to check to see if the "Surg_Type" field is NULL, and if so, then add tblMeasurement.MeasurementType to the field.
Then the following criteria (sorry for the coding):
If Surg_Type in ('FinalRefraction', 'Refraction') then tblMeasurement.MeasurementType
else
If Surg_Type = 'LRI' and tblMeasurement.MeasurementType = "TORIC" then 'LRI+TORIC'
else
If Surg_Type = 'TORIC' and tblMeasurement.MeasurementType = "LRI" then 'LRI+TORIC'
So you can see sometimes you only need to evaulate the table that you are inserting into and sometime you need to evaluate the source and destination tables.
I am confused and I hope I didn't confuse you to. I tried to use CASE as well, but I think I am digging myself a deeper hole.
I know this is simple to a lot of you and can really use some help.
Thanks in advance