如何从两个表中选择字段

Adi*_*dil 5 sql

我需要选择这些字段-----

user_id,
sales_vertical,
partner_id,
category,
sub_category,
stage_id,
exp_revenue,
action,
action_date,
title_action,
date_action,
details from opportunity_history table
Run Code Online (Sandbox Code Playgroud)

tri_title,
tri_subtitle 
from res_partner table 
where res_partner.partner_id = opportunity_history.partner_id 
Run Code Online (Sandbox Code Playgroud)

在一个查询中.我们怎么能这样做?

谢谢阿迪尔

Tud*_*tin 12

为什么这么多的downvotes和没有评论?

试试:

SELECT 
    oh.ser_id,
    oh.sales_vertical,
    oh.partner_id,
    oh.category,
    oh.sub_category,
    oh.stage_id,
    oh.exp_revenue,
    oh.action,
    oh.action_date,
    oh.title_action,
    oh.date_action,
    oh.details,

    rp.tri_title,
    rp.tri_subtitle

FROM opportunity_history AS oh
  INNER JOIN res_partner AS rp
    ON rp.partner_id = oh.partner_id 
Run Code Online (Sandbox Code Playgroud)

  • 但是,他们也应该告诉他 - 我也不喜欢懒惰的人,但我认为他们可能会被帮助纠正:) (3认同)

Bal*_*ash 1

SELECT a.user_id, a.sales_vertical, a.partner_id, a.category, a.sub_category, 
a.stage_id, a.exp_revenue, a.action, a.action_date, a.title_action, a.date_action, 
a.details, b.tri_title, b.tri_subtitle FROM opportunity_history a, res_partner b 
WHERE b.partner_id =a.partner_id
Run Code Online (Sandbox Code Playgroud)