There are several status an the status table. I want query like that.
select * from command where status <> 's' and status<> 'sc'
But query retrieve data with 'Status' S. What was the issue on that?
Is the status in the DB S
or s
?
Try
select * from command where lower(status) NOT IN ('s', 'sc')
Just try it.. No need to check lower or caps. It searches all letter (not case sensitive).
select * from command where status NOT IN ('s', 'sc')
If you want to add condition with case sensitive, then you have to use like this..
select * from command where status COLLATE Latin1_General_CS_AS NOT IN ('s', 'sc')
The checks Col <> 's'
depends on the collation of the columns. If the collation is case insensitive, then 'S' = 's'
and your checks will not return S
. If your collation is case sensitive which I believe is the case, will return S
.
For example note the following two collations Latin1_General_CI_AS_KS_WS
and Latin1_General_CS_AS_KS_WS
. Note the difference in case CI
and CS
.
SELECT 'S' WHERE 'S' <> 's' COLLATE Latin1_General_CI_AS_KS_WS
Does not return anything
SELECT 'S' WHERE 'S' <> 's' COLLATE Latin1_General_CS_AS_KS_WS
Returns S
Coming back to your query. If this case insensitive check is a one time thing you can either as suggested by other answers do a UPPER(Col)
/ LOWER(Col)
or use COL COLLATE Latin1_General_CI_AS_KS_WS
.
If all comparisons should be case insensitive, I would suggest changing the collation of the column itself.
status
?