从两个表#MYSQL检查用户名是否可用

问题描述 投票:0回答:1

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

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个回答
0
投票

立即检索它们,然后检查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
© www.soinside.com 2019 - 2024. All rights reserved.