INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

SQL Like statement with multiple values

SQL Like statement with multiple values

(OP)
Hi all, I tried searching for a previous example however using the work 'like' gives many, many results :)

I have a report I've inherited and I'm stuck on a problem.  Querying MS SQL Server and I'm trying to get a list of Object_IDs.

Example of table 1

Date_field, object_id, data_field1, data_field2...
20081201, CS4_1_194, 524, 23.....

Example of table 2

Object_ID, Object_Name, Object_Type...
CS4_1_194, 396628@dsm_siemens_hicom, 4

Obviously I can use Object_ID from both tables however the data handed to me includes an extensive list of items, all given with Object_Name instead of Object_ID.  What I want to do is find the Object_IDs to build another query.

I know I can
select Object_ID from Table2 where Object_Name like '396628@%'

What is the format if I want to include several of those names?  The following error gives me syntax errors.

Select Object_ID from Table2 where Object_Name
like ('396628@%', '396629@%', '396630@%')


Thanks in advance for any help!
 

RE: SQL Like statement with multiple values

(OP)
Ok, so I do have to do it as ORs.    I found one example on the net after posting this question and was hoping there'd be a better solution.

Thanks much PH!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close