sql - Join Two Queries/Select Statement -


i don't know how explain it. trying join 2 select statements/queries. need include customer , supplier name in same table.

table 1 - j: job id, customer id table 2 - jl: job_line.job_id, supplier_id table 3 - p: id, name 

first select statement - customer name:

select name p inner join j on p.id = j.customer_id 

second select statement - supplier name:

select name p inner join jl on p.id = jl.supplier_id 

don't know how join above 2 selects, have table like:

id, customer name, supplier name 

i new sql , learning online. understand basis, getting stuck @ finding complex!

this should trick

select j.id, pc.name, ps.name j inner join p pc on j.customer_id = pc.id inner join jl on j.id = jl.job_id inner join p ps on jl.supplier_id = ps.id 

note, pc , ps table aliases.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -