Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how To select fields from two tables

Tags:

sql

I need to select these fields-----

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

and

tri_title,
tri_subtitle 
from res_partner table 
where res_partner.partner_id = opportunity_history.partner_id 

in a single query. how can we do that?

Thanks Adil

like image 540
Adil Avatar asked Jul 01 '11 07:07

Adil


1 Answers

Why so many downvotes and no comments?

Try with:

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 
like image 128
Tudor Constantin Avatar answered Nov 15 '22 04:11

Tudor Constantin