1
create table test(variable varchar(20), col001 real, col002 real);
insert into test values('col001',1,2);
insert into test values('col002'3,4);

Now, I'd like to query this to get a submatrix:

 select variable, col001, col002
 from test
 where strpos("col001,col002", variable) > 0

Why doesn't this work?

Ilonpilaaja
  • 1,169
  • 2
  • 15
  • 26

2 Answers2

1

"col001,col002" is a delimited identifier, i.e. the dbms thinks it's a column name. Use single quotes for string literals.

I.e.

select variable, col001, col002
from test
where strpos('col001,col002', variable) > 0
jarlh
  • 42,561
  • 8
  • 45
  • 63
0

There is no STRPOS is MsSQL:
reference : SQL Server: any equivalent of strpos()?
you can write the query like this in MsSQL:

SELECT variable, col001, col002
FROM test
WHERE CHARINDEX('col001,col002', variable) > 0
Community
  • 1
  • 1
Biswabid
  • 1,378
  • 11
  • 26