sqlamazon-redshiftaginity

Joining using || - No results


This is what I am currently joining:

INNER JOIN us_raw.l_dmw_order_report t1 on t2.channel_uid = t1.customer_id

However, I need it so that it's like this instead:

INNER JOIN us_raw.l_dmw_order_report t1 on t2.channel_uid = ('UNU' || t1.customer_id)

When I do that, it does not seem to pull what I need, so I'm wondering if there is another way to do what I'm trying to do. Basically, t1's customer_id is t2's channel_uid, except with a 'UNU' in front of it (yea, idk who created this table but apparently that's the only difference, and I spot-checked to confirm).

Please let me know if you need more information, working with a confidential DB.

Thanks,


Solution

  • If I understand it right, you want to construct the value of t2.channel_uid by concatenating the prefix UNU and the value of t1.customer_id column. If that's the case, the following should work:

    INNER JOIN us_raw.l_dmw_order_report t1 on t2.channel_uid = CONCAT('UNU', t1.customer_id)
    

    Depending on what data types of your columns, you may need some type casting.