I would like to query only string that contains this exact string string_
.
I tried this:
select * from table where name like "%string_%"
and results also include string-
, but I need only exact _
.
Any help?
Thanks
_
is the wildcard in SQL for a single character. If you want to search for _
you need to escape it:
select *
from some_table
where name like '%string\_%' escape '\'
Additionally: string literals are put into single quotes in SQL. If you ever want to use a more standard compliant DBMS (Oracle, Postgres) you should get used to using single quotes for strings. Double quotes are only for identifiers (and should essentially be avoided in the first place)