MySQL如何多表合并查询?

SELECT * FROM question, WHERE title LIKE '%的%' OR selection LIKE '%的%';
SELECT * FROM doctortype WHERE title LIKE '%的%' OR selection LIKE '%的%';
SELECT * FROM teachertype WHERE title LIKE '%的%' OR selection LIKE '%的%';
SELECT * FROM computertype WHERE title LIKE '%的%' OR selection LIKE '%的%';

我想同时一条语句得到这四个表的数据要如何写?

阅读 2k
3 个回答

使用union all

数据都放到ES里查询

# union all
select * from t_file where id = 1 union all select * from t_file where id = 10

# a.*,b.*
select a.*,b.* from (select * from a) as a,(select * from b) as b
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题