Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter a field containing a value

Tags:

sql-server

I'm starting to learn SQL. Im using SQL Server Management Studio to write my queries in. I unserstand that I can filter a field contaning a given value (for example : product A, product A (cost), product B, product B (cost)) so in this instance I can filter out values containing "(cost)". I've arrived at the following query but its failing. Can you tell me why.

SELECT     billing_code, billing_code_desc
FROM         dbo.jm_billing_code
WHERE     (NOT (billing_code_desc = N'CONTAIN [(cost)]'))
ORDER BY billing_code
like image 790
Valery Avatar asked May 25 '26 12:05

Valery


1 Answers

N'CONTAIN [(cost)]' is a string literal, you can't place functions like contain in there.

Try this instead:

where billing_code_desc not like '%(cost)%'
like image 88
Andomar Avatar answered May 31 '26 20:05

Andomar