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,566
  • 7
  • 26
  • 42

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,222
  • 20
  • 25
0

Old school style without regexp

where length(translate(username, '_''`~()', '_')) <> length(username)
Dr Y Wit
  • 2,000
  • 9
  • 16