Home All Groups Group Topic Archive Search About
Author
2 Dec 2005 1:40 PM
Amon Borland
Is there an easier way to write the WHERE clause when the same column is
compared over and over again?  I need to pull by 360 zip codes.  Instead of
Where Zipcode = '12345' OR Zipcode = '54321' OR......and so on.

Something like Where Zipcode = OR{12345,54321,12342...}would be what i'm
looking for.

Thanks

Author
2 Dec 2005 1:52 PM
impslayer
Amon Borland skrev:

> Is there an easier way to write the WHERE clause when the same column is
> compared over and over again?  I need to pull by 360 zip codes.  Instead of
> Where Zipcode = '12345' OR Zipcode = '54321' OR......and so on.
>
> Something like Where Zipcode = OR{12345,54321,12342...}would be what i'm
> looking for.
>
> Thanks

That would be 'IN', like "WHERE zipcode IN ('12345', '54321', ...)".

Be sure using the correct data type, though, 12345 or '12345'...

   /impslayer, aka Birger Johansson
Author
2 Dec 2005 1:59 PM
Raymond D'Anjou
To add to impslayer's response.
Are you saying that you have 360 zipcodes in your WHERE clause?
Exactly what are you doing?
One solution, that may or may not apply to your problem, is to insert the
zipcodes into a temp table and join on that table.
Can you give us a bit more information?

Show quote
"Amon Borland" <AmonBorland@+nospam+gmail.com> wrote in message
news:ubuTIY09FHA.1332@tk2msftngp13.phx.gbl...
> Is there an easier way to write the WHERE clause when the same column is
> compared over and over again?  I need to pull by 360 zip codes.  Instead
> of Where Zipcode = '12345' OR Zipcode = '54321' OR......and so on.
>
> Something like Where Zipcode = OR{12345,54321,12342...}would be what i'm
> looking for.
>
> Thanks
>
>
>
Author
2 Dec 2005 2:24 PM
Amon Borland
Yes thats what I'm saying.  I have to pull all clients that have a zipcode
matching one of the 360.  I was asking what the shorthand way of doing this
was, like as a set of data.  WHERE IN seems like it will work although I'm
having data conversion issues.

Show quote
"Raymond D'Anjou" <rdanjou@canatradeNOSPAM.com> wrote in message
news:eu7NFj09FHA.3608@TK2MSFTNGP09.phx.gbl...
> To add to impslayer's response.
> Are you saying that you have 360 zipcodes in your WHERE clause?
> Exactly what are you doing?
> One solution, that may or may not apply to your problem, is to insert the
> zipcodes into a temp table and join on that table.
> Can you give us a bit more information?
>
> "Amon Borland" <AmonBorland@+nospam+gmail.com> wrote in message
> news:ubuTIY09FHA.1332@tk2msftngp13.phx.gbl...
>> Is there an easier way to write the WHERE clause when the same column is
>> compared over and over again?  I need to pull by 360 zip codes.  Instead
>> of Where Zipcode = '12345' OR Zipcode = '54321' OR......and so on.
>>
>> Something like Where Zipcode = OR{12345,54321,12342...}would be what i'm
>> looking for.
>>
>> Thanks
>>
>>
>>
>
>
Author
2 Dec 2005 2:37 PM
Raymond D'Anjou
Are the zipcodes you're comparing to always the same ones?
Concerning your data conversion issues, is the zipcode column defined as a
string or number datatype?

Show quote
"Amon Borland" <AmonBorland@+nospam+gmail.com> wrote in message
news:eKQrew09FHA.912@TK2MSFTNGP11.phx.gbl...
> Yes thats what I'm saying.  I have to pull all clients that have a zipcode
> matching one of the 360.  I was asking what the shorthand way of doing
> this was, like as a set of data.  WHERE IN seems like it will work
> although I'm having data conversion issues.
>
> "Raymond D'Anjou" <rdanjou@canatradeNOSPAM.com> wrote in message
> news:eu7NFj09FHA.3608@TK2MSFTNGP09.phx.gbl...
>> To add to impslayer's response.
>> Are you saying that you have 360 zipcodes in your WHERE clause?
>> Exactly what are you doing?
>> One solution, that may or may not apply to your problem, is to insert the
>> zipcodes into a temp table and join on that table.
>> Can you give us a bit more information?
>>
>> "Amon Borland" <AmonBorland@+nospam+gmail.com> wrote in message
>> news:ubuTIY09FHA.1332@tk2msftngp13.phx.gbl...
>>> Is there an easier way to write the WHERE clause when the same column is
>>> compared over and over again?  I need to pull by 360 zip codes.  Instead
>>> of Where Zipcode = '12345' OR Zipcode = '54321' OR......and so on.
>>>
>>> Something like Where Zipcode = OR{12345,54321,12342...}would be what i'm
>>> looking for.
>>>
>>> Thanks
>>>
>>>
>>>
>>
>>
>
>

AddThis Social Bookmark Button