忽略#,\,/,大写,$ in mysql选择查询

时间:2012-07-30 16:01:56

标签: php mysql select

我在下拉列表中填充所有用户名。我想忽略包含#\/uppercase$中的任何一个的用户名。我正在执行此查询,但仍显示\的记录,例如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;

任何建议????

谢谢......

2 个答案:

答案 0 :(得分:2)

SELECT
  account_name 
FROM
  dba_account 
WHERE 
  CAST(account_name  AS BINARY) RLIKE '[a-z]' 
  AND account_name NOT RLIKE '[#$\\\\/]'
LIMIT 50;

答案 1 :(得分:0)

您的查询

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;

不包含排除反斜杠的逻辑。