0

I am using oracle database and trying to find out the query which should return the result when there is a special character(',`,(,)) exist on the string.

I am trying something like this,

select username from users where username like (',`,~,(,));

I tried to achieve the same using the below query,

select username from users where (username like '%`%' OR username like '%~%');

It doesn't consider the second condition and returns the value to the first condition only.

Is there any function/methods using which this result can be fetched?

Aravindhan
  • 3,430
  • 7
  • 23
  • 40

2 Answers2

1

You can use regular expressions and check all special characters with one condition:

SELECT username 
FROM users 
WHERE regexp_instr(username,'[''`\(\)]') > 0
pablomatico
  • 2,191
  • 18
  • 25
0

Old school style without regexp

where length(translate(username, '_''`~()', '_')) <> length(username)
Dr Y Wit
  • 1,787
  • 6
  • 14