2

I am populating all usernames in a dropdown list. I want to ignore usernames containing any of these #, \, /, uppercase, $. I am Executing this query, but it still displays records with \, for example ad\name.

select account_name from dba_account where CAST(account_name  AS BINARY) RLIKE '[a-z]' 
and account_name not like '%#%' and account_name not like '%$%' and account_name not like 
'%/%' limit 50;

Any suggestions????

Thank You...

2 Answers 2

2
SELECT
  account_name 
FROM
  dba_account 
WHERE 
  CAST(account_name  AS BINARY) RLIKE '[a-z]' 
  AND account_name NOT RLIKE '[#$\\\\/]'
LIMIT 50;
4
  • hey it still displays that record: ad\names
    – ashah142
    Jul 30, 2012 at 16:07
  • @Aashil Are you sure you're using the correct query? I've made a change to the answer a minute ago. Try again.
    – Tomalak
    Jul 30, 2012 at 16:10
  • yes...it's still showing that..i don't understand why...and it is also showing records with #..
    – ashah142
    Jul 30, 2012 at 16:36
  • @Aashil The \ must be double-escaped (i.e. not \\ , but \\\\ ). It's in the docs. Also mySQL's LIKE does not seem to support chracter classes (square brackets). RLIKE should be able to do it.
    – Tomalak
    Jul 30, 2012 at 16:45
0

Your query

select account_name from dba_account where CAST(account_name  AS BINARY) RLIKE '[a-z]' and account_name not like '%#%' and account_name not like '%$%' and account_name not like '%/%' limit 50;

doesn't contain logic to exclude backslashes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.