I want to query username like that in two tables, only one of the tables has this data to return true, but the MySQL judge must have two tables to return true.
Is there any way to implement such a query? (Returns True if there is data in any of the two tables)
Reply content:
I want to query username like that in two tables, only one of the tables has this data to return true, but the MySQL judge must have two tables to return true.
Is there any way to implement such a query? (Returns True if there is data in any of the two tables)
select * from user_agent, user_cleck where user_agent.username = 'huibao' or user_clerk.username = 'huibao'
Is that OK?
select * from table1, table2
is a multi-table joint query, the case of the main problem is only two single-table query results collection, should be used in union.
1. Result Collection
select * from user_agent where username='{$username}' union all select * from user_clerk where username='{$username}';
2, result collection, and remove duplicates
select * from user_agent where username='{$username}' union select * from user_clerk where username='{$username}';
The situation of the main problem, both kinds of can.