New answers tagged


The problem here is that using a function or or around your join predicate means that the database engine can not use any indexes that you might have defined on the relevant columns for seeking so it is forced to table scan. On a large table this can take a long time. Worse, if this is part of a larger query you might find the scanning must be done multiple ...


I'd approach this problem by writing a SELECT statement on T2 which selected either col1 or col2, like: SELECT col_to_join = coalesce(col1, col2) FROM T2 Then use this SELECT statement in the join.

Top 50 recent answers are included