Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to seach in a string

Author  Topic 

goligol
Posting Yak Master

128 Posts

Posted - 2011-10-24 : 10:10:23
Hi,

I have a table, I am having the following query, I would like to select from the table where the in a description of a column it sees the word"Egg"

SELECT TOP 1000 [hs_code]
,[hs_code_desc]
,[hs_code_desc2]
,[unit_qy1]
,[unit_qy2]
,[sitc]
,[end_use]
,[naics]
,[usda]
,[ hitech]
,[YYYYMM_from]
,[YYYYMM_to]
FROM [trade].[ft].[export_concord_07]

??????----where hs_code_desc2 includes "Egg" or "egg" ----??????????

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-10-24 : 10:15:27
select *
from tbl
where hs_code_desc2 like "%Egg%" or hs_code_desc2 like "%egg%"

will also give rows with 'Eggs' and 'asdeggasdds'

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

DBAPBFL
Starting Member

11 Posts

Posted - 2011-10-24 : 10:31:14
select *
from tbl
where hs_code_desc2 like "% Egg %" or hs_code_desc2 like "% egg %"

will NOT give rows with 'eggs' and 'asdeggsdds'

Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-10-24 : 10:37:37
quote:
Originally posted by DBAPBFL

select *
from tbl
where hs_code_desc2 like "% Egg %" or hs_code_desc2 like "% egg %"

will NOT give rows with 'eggs' and 'asdeggsdds'





Also won't give rows with ' egg, ccc' 'egg' 'egg ccc' 'sd egg'

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

goligol
Posting Yak Master

128 Posts

Posted - 2011-10-24 : 10:43:49
thank you.
Go to Top of Page
   

- Advertisement -