Skip to content
Advertisement

Combine two tables with different columns and data

How can I combine two tables with different data and set value for CompanyC to all data in Table 2 even there is no relationship of CompanyC on Table2.

And the Result Table would be like:

I already tried this and it is working but the problem is since CompanyC has no data on Table 2. The result will be null.

Advertisement

Answer

You can do an INNER join of the tables and use NOT EXISTS in the ON clause like this:

See the demo.
Results:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement