sqlamazon-redshiftdbvisualizer

SQL join table on a modified key


I am trying to join table on a modified key. I am getting b.buser does not exist.

SELECT 
a.name,
a.work_id,
a.email_id,
a.Legal_name,
b.username,
left(b.username,11) as buser,
b.email,
FROM a
left join b on a.work_id=b.buser

Solution

  • I can only believe the parser: b.buser doesn't exist.

    Looking at your SQL, you're probably trying to reference left(b.username,11), which you aliased to buser. This is different than b.buser.

    Try this one:

    left join b on a.work_id=left(b.username,11)