[英]Selected columns in sub query(Multiple column) are not showing
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 These columns are not showing in result set. pap.lead_price,pap.live,pap.allocation_id,pap.affiliate_id这些列未显示在结果集中。 Please help!!! 请帮忙!!!
Short Answer 简短答案
Add ,pafp.lead_price,pafp.live,pafp.allocation_id,pafp.affiliate_id
to the end of your Select
just before From
添加,pafp.lead_price,pafp.live,pafp.allocation_id,pafp.affiliate_id
您结束Select
之前From
Suggestions 意见建议
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
add those column in parent select statement.. like 在父选择语句中添加这些列。
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.