select daf.id as affiliate_id,daf.name as affiliate_name,
dal.name as allocation_name,dal.id as allocation_id,dal.allocation,dal.price
from degreeamerica.affiliates daf join degreeamerica.allocations dal
JOIN(select pap.lead_price,pap.live,pap.allocation_id,pap.affiliate_id from paul.affiliates_price pap) pafp on (dal.id=pafp.allocation_id and daf.id=pafp.affiliate_id) order by daf.id;
pap.lead_price,pap.live,pap.allocation_id,pap.affiliate_id 这些列未显示在结果集中。请帮忙!!!
答案 0 :(得分:1)
简答
在,pafp.lead_price,pafp.live,pafp.allocation_id,pafp.affiliate_id
Select
添加到From
的末尾
<强>建议强>
SELECT
daf.id AS affiliate_id,
daf.name AS affiliate_name,
dal.name AS allocation_name,
dal.id AS allocation_id,
dal.allocation,
dal.price,
pap.lead_price, -- add the fields you want from paul.affiliates_price
pap.live,
pap.allocation_id,
pap.affiliate_id
FROM
degreeamerica.affiliates daf
JOIN degreeamerica.allocations dal -- what are we joining on?
-- why create a subquery with no filters? just join to table.
JOIN paul.affiliates_price pap ON dal.id=pap.allocation_id
and daf.id=pap.affiliate_id
ORDER BY
daf.id
答案 1 :(得分:1)
在父选择语句中添加这些列。 像
select daf.id as affiliate_id,
daf.name as affiliate_name,
dal.name as allocation_name,
dal.id as allocation_id,
dal.allocation,
dal.price,
pafp.lead_price,
pafp.live,
pafp.allocation_id,
pafp.affiliate_id
from degreeamerica.affiliates daf JOIN
degreeamerica.allocations dal JOIN
(select
pap.lead_price as lead_price,pap.live as live,
pap.allocation_id as allocation_id,
pap.affiliate_id as affiliate_id
from paul.affiliates_price pap
) pafp on dal.id=pafp.allocation_id and daf.id=pafp.affiliate_id
order by daf.id;