Skip to content
Advertisement

sql table comparisons – postgres

I have two tables with some columns being the same:

TABLE A


TABLE B

I’d like to return the following:

How do I check what rows from table B are in table A and also return Col4 (from table B) where they match in the query. I was using EXCEPT which worked great but now I need to have the outputs of Col4 in the returned query results.

Thanks.

Advertisement

Answer

Something like this?

(Using IS NOT DISTINCT FROM to say that columns with null are equal to each other.)

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