I am using PostgreSQL and must join tables using substring. As I demonstrated below, xyz.MODEL and first three characters of "columnname" from abc Table should match. However, the query below does not work.
SELECT ..., ..., ..., ...
FROM ... AS abc
INNER JOIN ... AS xyz ON abc.SUBSTRING("columnname",1,3) = klm.MODEL
It returns the error:
ERROR: schema "abc" does not exist
Can anyone help me to correct this query?
Thanks for your help already.
CodePudding user response:
The table alias must precede the column name, not the function:
SELECT ...
FROM ... AS abc
JOIN ... AS xyz ON SUBSTRING(abc."columnname",1,3) = klm.MODEL
^
here