【问题标题】:Check Username availability from two tables #MYSQL检查两个表中的用户名可用性#MYSQL
【发布时间】:2020-05-23 02:27:47
【问题描述】:

我有两个表(radcheck 和其他用户) 我想首先检查“radcheck”表中是否存在用户 如果用户不在那里,我想检查“其他用户”表。 这是我到目前为止所做的,但每次我尝试都会出现错误或根本不起作用。 如果您知道我可以做到的更好方法,那也会有所帮助。谢谢

authreply_table = radcheck
authreply_table2 = otherusers

nauthorize_reply_query = "\ 
  select id, username, attribute, value, op \ 
  from ${authreply_table} \ 
  CROSS JOIN ${authreply_table2} \
  where username = '%{sql-user-name}' \ 
  order by id"

【问题讨论】:

    标签: mysql sql freeradius radius


    【解决方案1】:

    同时检索它们,并检查 tbl 以查看它来自哪个表。

    select 1 as tbl, id, username, attribute, value, op \ 
      from ${authreply_table} \ 
      where username = '%{sql-user-name}' \ 
    UNION
    select 2, id, username, attribute, value, op \ 
     ${authreply_table2} \
      where username = '%{sql-user-name}' \ 
    order by tbl,id
    

    【讨论】:

      猜你喜欢
      • 2016-02-25
      • 1970-01-01
      • 2014-04-01
      • 1970-01-01
      • 2015-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多