Home Postgres: join if field is not null in both tables?
Reply: 0

Postgres: join if field is not null in both tables?

user4949
1#
user4949 Published in September 21, 2018, 2:41 am

I'd like to join two tables in Postgres, but only if the value is not NULL in both fields.

It appears to me that a query like this will actually behave like this already, without further conditionals:

SELECT * FROM aTable a JOIN bTable b on a.value=b.value;

This doesn't return rows from my database where both a.value and b.value are NULL.

However, I'm not totally confident I understand what's going on. Is this because NULL is not equal to NULL in Postgres?

share|improve this question

2 Answers 2

active oldest votes
up vote 2 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.335157 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO