MYSQL - Concatenate two tables

北城余情 提交于 2019-12-05 15:58:20
select * from table_a where actid = 17
union all
select * from table_b where actid = 17

You may (or may not) need to do something about the ids not being unique, such as

select 'Student', table_a.* from table_a where actid = 17
union all
select 'Faculty', table_b.* from table_b where actid = 17

You want UNION ALL:

(SELECT * FROM tablea) UNION ALL (SELECT * FROM tableb)

I think those parenthese are correct. I remember MySQL being fussy about this.

its too easy select tableA.stuId,tableA.actId, tableB.facId,tableB.actId from tableA,tableB where tableA.actid=tableB.actid;`

programmer master

You can concatenate these two tables by using select, from and where.

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