Hello All!
I didn't see a place for SQL commands and I apologize if I overlooked it, but i'm really stuck on this.
Heres the situation: I need update a column from my table (T1) from two other columns in a different table (T2).
My constraints are:
•That I have to match the first 4 letters of a column in T2 to one column in T1
•I have to identify that the first letter in a column in T1 corresponds to one letter in the middle of a string in a column in T2
For instance:
My Table (T1):
Order Type Combined Place
0090 0001 YYXX 1YY
0091 1001 YYXX YYY
0092 1002 XXXX 2XX
Table 2 (T2):
Order Value
00900001YY XX
00911001YY XX
00921002XX XX
The Combined column in T1 is what i'm trying to complete.
The T1.Place column contains the first character that I want to check for.
•If it's a "1" then I want to make sure the 5th letter in T2.Order is a "0"
•If its a "Y" then I want to look for a "1001"
•If its a "2" then I want to make sure the 8th letter is a "2" in T2.Order
If all that matches then I was the last two letters in T2.Order + T2.Value to be combined and put into the appropiate spot in T1.Combined
Here's what I have:
UPDATE MyTable
SET T1.Combined = RIGHT(T2.Order,2) + T2.Value
FROM MyTable1 T1, MyTable2 T2
WHERE T1.Order = LEFT(T2.Order, 4) AND
IF LEFT(T1.Clin, 1) = '1' THEN
IF SUBSCRIPT(T2.Clin, 5, 1) = '0' THEN
END IF
END IF
I know it's a little complex, but i'm really stuck on it and any help would be greatly appreciated. Thanks to all in advance!