HELP .......... SQL query
I have a table(Test) with four columns(ID, OP1, OP2, OP3) which contains options structure is like this.
ID OP1 OP2 OP3
--- ---- ---- ----
1 NULL NULL NULL
2 ABC NULL NULL
3 DEF DEF NULL
4 GHI GHI GHI
I have to retrieve ID from test table where a string of three characters is in OP1 and OP2 and OP3 column but if value is null in the next column no need to check further.
Example: I want to pick ID for string DEF. So my condition in query should become.
select ID from test where OP1 = 'DEF' and OP2 = 'DEF';
And if I am looking for GHI so my query should be this
select ID from test where OP1 = 'GHI' and OP2 = 'GHI' and OP3 = 'GHI';
Please help me and propose optimum query or way to achieve this result.
Thanks in advance
WAK
|