473,419 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

How to compare a variable against multiple values in MSSQL

How to compare a SQL variable against multiple values:

Here is the scenario;

Expand|Select|Wrap|Line Numbers
  1. Declare @JobTitle varchar(10)
  2.  
  3. Select @JobTitle = JobTitle from tableName where xxx=xxx
Now I want to compare @JobTitle value against multiple strings without using OR in the IF statement?

Expand|Select|Wrap|Line Numbers
  1. if @JobTitle = 'AAAAA' OR @JobTitle = 'BBBBBB' OR @JobTitle = 'CCCCC' ...... 
instead of using multiple OR, is there any other way to accomplish this?
Sep 19 '10 #1
1 11718
gpl
152 100+
Use IN, for example
Expand|Select|Wrap|Line Numbers
  1. @JobTitle IN ('AAAAA', 'BBBBBB', 'CCCCC') 
Sep 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Roland Hall | last post by:
Is there a way to return multiple values from a function without using an array? Would a dictionary object work better? -- Roland Hall /* This information is distributed in the hope that it...
2
by: Chaz | last post by:
Hello, I hope someone can help me out. I am going to be taking the third step in a programming class soon(I took the previous two a while ago at a different school) and in an effort to get back up...
0
by: RJN | last post by:
Hi My web service receives an object of type say MyObject. I want to serialize this object,and then validate the xml against the main xsd. When validation happens, it should also validate...
16
by: Nikolay Petrov | last post by:
How can I return multiple values from a custom function? TIA
5
by: Jason | last post by:
Is there a mechanism in VB.NET that allows something like: If myVar In ("A","B","C") Then... The way I'm doing it now is: Select Case myVar Case "A","B","C" Or like this:
8
by: Chris A via AccessMonster.com | last post by:
I have an interesting problem that I have yet to come accross that I can't change data structure on because it is an export from filemaker I am reformatting for another dept. anyway. I have a table...
5
by: paul_zaoldyeck | last post by:
does anyone know how to validate an xml file against multiple defined schema? can you show me some examples? i'm making here an xml reader.. thank you
17
by: wswilson | last post by:
In python, I could write: a = 1 if a in : do something... In c (and many other languages):
1
by: sarankarthik | last post by:
Hi, I have some array of values,say for example Attribute1 contains 1,2,3,4,5,6,7 values.. Please tell me how can i store multiple values in an xml file for a single variable. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.