Ask Your Question

Revision history [back]

If the desired column for joining is empty or null, the following steps can be taken:

  1. Use the IS NULL operator to check for null values in the joining column. For example:

SELECT * FROM table1 JOIN table2 ON table1.column1 = table2.column2 or table1.column1 IS NULL

  1. Use the COALESCE function to replace null values with a default value. For example:

SELECT * FROM table1 JOIN table2 ON COALESCE(table1.column1, 'defaultValue') = table2.column2

  1. Use a LEFT OUTER JOIN if you want to include all the rows from the left table even if there is no match on the joining column. For example:

SELECT * FROM table1 LEFT OUTER JOIN table2 ON table1.column1 = table2.column2

  1. Consider using a different column for joining if the desired column is consistently null or empty.