?
Solved

SQL LIKE function for table field not string literal

Posted on 2007-03-22
2
Medium Priority
?
192 Views
Last Modified: 2010-03-19
I am using SQL Server Express 2005.

I need to do a string compare in my query and it is something similar to:
ItemTexts.BookTitle LIKE '%Dictionary%'

In the above case I am checking for the existance of the string literal within the ItemTexts.BookTitle field.

However, instead of a string literal, the string to check is contained in another table field. But I obviously cannot do:
ItemTexts.BookTitle LIKE '%ItemCategories.LookupString%'

Can you explain how I can achieve the above bearing in mind it is between table fields?
0
Comment
Question by:mike99c
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 18776961
ItemTexts.BookTitle LIKE '%'+ItemCategories.LookupString+'%'
0
 

Author Comment

by:mike99c
ID: 18777224
Great thanks, I should have known about the string concatenation.Nice easy 500 points for you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question