gpt4 book ai didi

sql - 我可以在一个查询中选择两个表吗?

转载 作者:搜寻专家 更新时间:2023-10-30 21:55:37 26 4
gpt4 key购买 nike

我有2张 table

  1. 费用
  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

有没有可能得到这样的结果。

最佳答案

使用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

关于sql - 我可以在一个查询中选择两个表吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55024475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com