我想将这两个查询放入一个查询中。查询的目的是检查凭证是否与表中的任何一个匹配" user_credentials"或"工人"。我怎么能这样做?
SELECT user_name FROM user_credentials WHERE user_name =' $ user_email' AND password =' $ user_password'
SELECT user_name FROM workers WHERE user_name =' $ user_email' AND password =' $ user_password'
答案 0 :(得分:1)
试试这个
SELECT user_name FROM user_credentials WHERE user_name = '$user_email' AND password = '$user_password'
union
SELECT user_name FROM workers WHERE user_name = '$user_email' AND password = '$user_password'
然后检查mysqli_num_rows
或mysql_num_rows