create table test(variable varchar(20), col001 real, col002 real);
insert into test values('col001',1,2);
insert into test values('col002'3,4);
现在,我想查询这个以获取子矩阵:
select variable, col001, col002
from test
where strpos("col001,col002", variable) > 0
为什么这不起作用?
答案 0 :(得分:1)
"col001,col002"
是一个分隔标识符,即dbms认为它是一个列名。使用单引号作为字符串文字。
即
select variable, col001, col002
from test
where strpos('col001,col002', variable) > 0
答案 1 :(得分:0)
MsSQL没有STRPOS
:
参考:SQL Server: any equivalent of strpos()?
你可以在MsSQL中编写这样的查询:
SELECT variable, col001, col002
FROM test
WHERE CHARINDEX('col001,col002', variable) > 0