checkmofoshoduno
asked on
How can i rewrite the following SQL statement?
How can i rewrite the WHERE clause with out using the use of IN special operator:
WHERE L_ST IN (‘WA’, ‘ID’, ‘NY’)
WHERE L_ST IN (‘WA’, ‘ID’, ‘NY’)
WHERE L_ST =‘WA’ or L_ST= ‘ID’ or L_ST='NY’
You can use OR like mayank_joshi said, but if I was you, I'd leave the IN ( ) ...
It's easier to read and will not mess with any other condition you may add ( you will need to use parenthesis or similar.)
Cheers
It's easier to read and will not mess with any other condition you may add ( you will need to use parenthesis or similar.)
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@anushahanna
union all probably
What are you actually asking us...
why do you need to re-write the statement...
as with most sql comparisons if the set of data is going to be repeatedly used then it should
be set up on a table and reference (via a Join) that way....
create table State_groups (collection_name char(10) not null, grouping_name char(10) not null,
State_alias cjar(2) not null, primary key (collection_name,grouping_
e.g. 'UPSPOSTRATE','MIDWEST','W
....
from Yourtable as x
inner join state_groups as s
on x.l_st- s.state_alias
and s.collection_name='UPSPOST
and s.grouping_name='MIDWEST'