Sample Header Ad - 728x90

Is there an equivalent sql check to python's concept of truthy / falsy / bool?

0 votes
2 answers
778 views
I'm trying to find the usage of particular columns in a **mysql** database connected to python. Python counts the following to be 'falsy': - Empty lists: [] - Empty tuples: () - Empty dictionaries: {} - Empty strings "" - Integer: 0 - Float: 0.0 - None - False I realise this is somewhat ORM dependent (e.g. empty datatypes are stored as NULL rather than a string) but is the below somewhat equivalent, is there a better way and is there anything obvious I'm missing? Maybe 0.0? The idea being to calculate a row_count and subtract this result. I tried NOT IN for truthy but didn't seem to get a consistent result.
SELECT COUNT(*) FROM tabBatch WHERE naming_series IN ('', 0, NULL);
Asked by racitup (103 rep)
Mar 11, 2022, 02:19 AM
Last activity: Mar 14, 2022, 01:20 AM