[英]Is there a way to concat two columns from a table and join three tables
I am trying to join three tables, but in one of the tables I need to concat two columns for being able to do the left join.我正在尝试连接三个表,但在其中一个表中,我需要连接两列才能进行左连接。
select * from
order_dupe_check_cleaned dcc left join AAPEN_SORLIN asr
on dcc.INTERNAL_ORDER_ID = asr.VLCODE
left join order_dupe_atributes oda on dcc.INTERNAL_ORDER_ID = oda.INTERNAL_ORDER_ID
and oda.product_id = --** Here I want to insert the concat statement**(select concat_ws(VLDEPT,VLSTYL)as product_id2 pi from AAPEN_SORLIN)
where dcc.order_id like '73901124'
;
I have used (+) instead (||) as this one was giving me duplicates, so I was trying to link the three tables by using left join however, one of the tables does not contain product_id but it has two columns (VLDEPT,VLSTYL) that together give the product_id that is why I wanted to use concat.我已经使用 (+) 而不是 (||) 因为这个给了我重复项,所以我试图通过使用左连接来链接三个表但是,其中一个表不包含 product_id 但它有两列(VLDEPT, VLSTYL) 一起给出了 product_id 这就是我想使用 concat 的原因。
With strings you can concatenate simply by using ||.对于字符串,您可以简单地使用 || 进行连接。
Because you've already joined the fields via left join AAPEN_SORLIN asr
you should be able to access them directly.因为您已经通过
left join AAPEN_SORLIN asr
加入了字段,所以您应该能够直接访问它们。
select
*
from
order_dupe_check_cleaned dcc
left join AAPEN_SORLIN asr
on dcc.INTERNAL_ORDER_ID = asr.VLCODE
left join order_dupe_atributes oda on dcc.INTERNAL_ORDER_ID = oda.INTERNAL_ORDER_ID
and oda.product_id = VLDEPT||VLSTYL
--** Here I want to insert the concat statement**(select concat_ws(VLDEPT,VLSTYL)as product_id2 pi from AAPEN_SORLIN)
where dcc.order_id like '73901124'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.