Applying LIKE function on column
How can I in Teradata apply LIKE function on column name. I wrote the following code:
SELECT * FROM sb LEFT JOIN asa ON asa.column_1 LIKE '%sb.column_2%'
This is not returning the result I want sb.column is COLUMN (with varible values) and not the string I am trying to find.
Edit: Actually I am trying to find a substring in a string. Which function do I have to use and how?
'%sb.column_2%' searches for the string 'sb.column_2' within asa.column_1. You probably need
ON asa.column_1 LIKE '%' || sb.column_2 || '%'
You could also use
ON POSITION(sb.column_2 IN asa.column_1) > 0
But both will always result in a product join which will consume a lot of CPU unless at least one table has a low number of rows. Your DBA will definitely not like that :-)
This join probably indicates a bad datamodel, it should be fixed first thus avoiding bad joins like this.