• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

a filed included with another field ms sql

I have a table with 2 fields field1 and field2 both are char fields

I would like a where:

select * from table where field1 like '%' & field2 & '%'

I just does not work
0
robrodp
Asked:
robrodp
  • 3
  • 2
1 Solution
 
Kevin CrossChief Technology OfficerCommented:
+ is the concatenation operator in SQL. & is a bitwise operator.
0
 
Kevin CrossChief Technology OfficerCommented:
In other words,
select * from table where field1 like '%' + field2 + '%';

Open in new window

0
 
robrodpAuthor Commented:
It returns just those records where field1=field2
0
 
robrodpAuthor Commented:
One record field1='James Bond' field2='Bond'


select * where field1 like '%' + field2 + '%'

returns nothing

select * where field1 like '%Bond%'

returns the record????
0
 
robrodpAuthor Commented:
Thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now