Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • 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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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