All Forums Database
dsldsl1980 11 posts Joined 07/12
13 Feb 2013
Can you join using wild cards col_a like %col_b%

I know you can use wild cards in your where clause to filter results but how can you join on them?  IE: I have 2 tables
Table1 column = 'Teradata is great'
Table2 column = 'data'
How can I get these 2 tables to join?  I know you could substring it out but I need to to work similar to a like clause.
 
Thanks!
 

ulrich 816 posts Joined 09/09
14 Feb 2013

try 
cards col_a like '%' || col_b || '%'
 

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

dnoeth 4628 posts Joined 11/04
14 Feb 2013

Just a remark:
When you join like this, you'll always get a product join and you got a really strange data model.
Dieter 

Dieter

ulrich 816 posts Joined 09/09
15 Feb 2013

Strange data model: Depends on the use case. 
Can be very sufficient for specific problems. For example data quality checks ELT processes. Filter out email addresses containing specific pattern or domains etc. 
Or I used it for very flexible filter rules with multiple columns where not all have to be fully specifed all the time...
True that this is a product join but still quite efficient. But fully agree that this should never be a standard join on normal table.
Ulrich

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

You must sign in to leave a comment.