table1中有一列col1,类型为varchar,其中有一行col1的内容为'abcdef'
要实现
select * from table1 where 'cde' in col1
或者
select * from table1 where col1 have 'cde'
该怎么写SQL语句呢?
------解决方案--------------------
- SQL code
select * from table1 where col1 like '%cde%'--或是select * from table1 where charindex('cde',col1)>0
------解决方案--------------------
- SQL code
declare @table1 table (col1 varchar(6))insert into @table1select 'aaa' union allselect 'abcdef' union allselect 'asdf' union allselect 'gasd' union allselect 'ssss'select * from @table1 where col1 like '%cde%'--或是select * from @table1 where charindex('cde',col1)>0 /*col1------abcdef*/
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
- SQL code
select * from table1 where col1 like '%cde%'
------解决方案--------------------