?? charindex.txt
字號:
B=(1,11,2,22,3)
select * from table where
charindex(',1,',','+B+',')>0 or charindex(',2,',','+B+',')>0
or charindex(',3,',','+B+',')>0
(2)
INSERT @t SELECT '消費電子'
UNION ALL SELECT '消費電子 '
UNION ALL SELECT ',消費電子,'
select * from @t where nkey='消費電子'
/*-- 結果
id nkey
----------- ----------
1 消費電子
2 消費電子
--*/
select *, ','+'消費電子'+',' from @t where charindex(','+'消費電子'+',',','+nkey+',')>0
/*-- 結果
id nkey
----------- ---------- ----------
1 消費電子 ,消費電子,
3 ,消費電子, ,消費電子,
(2 行受影響)
--*/
select * from @t where ','+'消費電子'+','=','+nkey+','
/*-- 結果
id nkey
----------- ----------
1 消費電子
(1 行受影響)
--*/
charindex(','+'消費電子'+',',','+nkey+',')>0
這個是包含關系
','+'消費電子'+','=','+nkey+','
這個是完全匹配關系.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -