Neha
Neha

Reputation: 646

SQL Server 2008 LIKE query

I want to use LIKE query to select some specific word just like UU1.

I use

SELECT UniID FROM MasterCustomer  where (UniID like '%uu1%' )

But it also returns a row which contains UU11.

How can I modify my query to select only UU1?

My table contains values like

UU1-UU7-UU5
UU2-UU1
UU3-UU1
UU31-UU14

Upvotes: 3

Views: 10671

Answers (3)

Andriy M
Andriy M

Reputation: 77687

Another alternative:

WHERE UnitID + '-' LIKE '%uu1-%'

Upvotes: 0

Sebastian Meine
Sebastian Meine

Reputation: 11813

try this:

SELECT UniID 
FROM MasterCustomer  
WHERE (UniID like '%uu1' ) OR (UniID like '%uu1-%' )

Upvotes: 3

paul
paul

Reputation: 22001

like '%uu1-%' or like '%uu1 %'

Upvotes: 0

Related Questions