I want to query username in two tables like that. If one table has this data, true is returned, but MySQL returns true only if both tables have this data. Is there any way to implement such a query? (If either of the two tables has data, true is returned)
I want to query username in two tables like that. If one table has this data, true is returned, but MySQL returns true only if both tables have this data.
Is there any way to implement such a query? (If either of the two tables has data, true is returned)
Reply content:
I want to query username in two tables like that. If one table has this data, true is returned, but MySQL returns true only if both tables have this data.
Is there any way to implement such a query? (If either of the two tables has data, true is returned)
select * from user_agent, user_cleck where user_agent.username = 'huibao' or user_clerk.username = 'huibao'
Can this happen?
select * from table1, table2
Multi-table joint query. The subject only obtains a collection of the results of two single-table queries.UNION.
1. Result collection
select * from user_agent where username='{$username}' union all select * from user_clerk where username='{$username}';
2. Retrieve the collection of results and remove repeated items.
select * from user_agent where username='{$username}' union select * from user_clerk where username='{$username}';
The subject can be either of them.