我有2张桌子
费用
fees id | fees_name | department | semester | hall_ticket | amount
--------------------------------------------------------------------
1 |Tution Fees| CSE | 2-1 | 1234 | 10000
附加费用
fees id | fees_name | department | semester | add.amount
--------------------------------------------------------------------
9 | Exam Fees | CSE | 2-1 | 5000
我想要这样
fees_name | department | semester | hall_ticket | amount
---------------------------------------------------------
Tution Fees| CSE | 2-1 | 1234 | 10000
Exam Fees | CSE | 2-1 | | 5000
是否可以得到这样的结果?
答案 0 :(得分:2)
使用UNION
select fees id , fees_name , department , semester , hall_ticket, amount from fees
union
select fees id , fees_name , department , semester , null, add.amount from additionalfees
答案 1 :(得分:1)
全部使用联盟
select fees_id,fees_name,department,semester,hall_ticket,amount from fees
union all
select fees_id,fees_name,department,semester,null,add.amount from additional_fees
答案 2 :(得分:1)
是的,您可以使用UNION函数。
SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
答案 3 :(得分:0)
最简单的方法是
SELECT * FROM table1, table2;