【问题标题】:How to merge SQL results?如何合并 SQL 结果?
【发布时间】:2020-04-14 17:11:58
【问题描述】:

关于合并 SQL 结果有很多问题。这是我的案例,它有两个不同的 SQL 结果。

userID   Car
1        Ford
2        Honda
3        Toyota
userID   Color
1        Red
2        Silver
3        White

有没有办法将以上两者合并到SQL中的以下内容中:

userID   Car      Color
1        Ford     Red
2        Honda    Silver
3        Toyota   White

【问题讨论】:

  • 这可以通过简单的 JOIN 来完成。
  • 我明白了。谢谢!

标签: mysql sql database oracle


【解决方案1】:

这看起来像join

select ca.user_id, ca.car, co.color
from cars ca join
     colors co
     on ca.user_id = co.user_id;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-28
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多