X
X
xxxfdd2021-12-21 21:48:30
Python
xxxfdd, 2021-12-21 21:48:30

How to make None equal to any value?

I have a script that compares two tables and displays values ​​if the values ​​in the two tables match, but it happens to me that the column is sometimes None and how to do that if it is non, then we skip
the script itself

SELECT * FROM woman t1, a688093622 t2
WHERE t1.age = t2.age
AND t1.growth = t2.growth
AND t1.hair = t2.hair
AND t1.size = t2.size
AND t1.weight = t2.weight

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tomulevich, 2021-12-22
@phoinixrw

Firstly, not None, but NULL
In principle, it is better to compare fields that can be NULL like this:
t1.field IS NOT DISTINCT FROM t2.field
Or like this, but longer:
COALESCE(t1.field, '') = COALESCE(t2.field, '')
In your case, if you want to exclude rows if there is NULL somewhere, then you can use the NULL property (when everything that interacts with NULL becomes NULL)

SELECT 
...
AND ( t1.age || t1.growth || t1.hair || t1.size || t1.weight ) IS NOT NULL
AND ( t2.age || t2.growth || t2.hair || t2.size || t2.weight ) IS NOT NULL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question