Multiple select statements for mysql search query

橙三吉。 提交于 2019-12-13 05:49:56

问题


can i use select statements for different tables in a single query

SELECT *
FROM users
WHERE first_name LIKE "%'.$search_string.'%"
   OR last_name LIKE "%'.$search_string.'%"

thats from the table ' users' , i want to do the same search on another table called sellers. sellers have the same fields first_name, last_name


回答1:


Yes, you can

Select column1,column2,column3,column4
From table1,table 2
Where Conditions

If you want to do join between tables, check if theirs PK and FK are equals Eg:

Select table1Id,table2Id,column3,column4
From table1 t1,table2 t2
Where t1=t2 


来源:https://stackoverflow.com/questions/19754965/multiple-select-statements-for-mysql-search-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!