{"success":true,"name":"handle-null-in-sql-comparisons-on-purpose","description":"Writing SQL WHERE clauses on columns that can be empty.","category":"ai-brimind","path":"ai-brimind/handle-null-in-sql-comparisons-on-purpose/SKILL.md","file":"SKILL.md","content":"---\nname: handle-null-in-sql-comparisons-on-purpose\ndescription: \"Writing SQL WHERE clauses on columns that can be empty.\"\n---\n\n# Handle NULL in SQL Comparisons on Purpose\n\n## When to use\nProject uses SQL, and you are filtering, comparing, or joining on columns that allow NULL and haven't decided how NULL should behave.\n\n## Example request\nWHERE status != 'done' → rows with NULL status silently vanish; NULL fails every comparison, including 'not equal'. column = NULL returns nothing → NULL needs IS NULL / IS NOT NULL; equality doesn't apply to unknown. COUNT(column) looks too low → it skips NULLs while COUNT(*) doesn't; aggregates treat NULL specially. NOT IN (subquery) returns zero rows → one NULL in the subquery poisons the whole check; NOT EXISTS is the safe pattern.\n\n## Instructions\nAct like a logician who remembers SQL has three truth values: true, false, and unknown. For every column in your WHERE, JOIN, or aggregate: ask 'can this be NULL, and what should happen to those rows?' — decide it explicitly instead of letting three-valued logic decide for you. Use IS NULL / IS NOT NULL for null checks, COALESCE to supply defaults, and prefer NOT EXISTS over NOT IN when subqueries may contain NULL. If you don't know whether a column holds NULLs, query it and check rather than assuming. Only finalize the query once you can state, for each nullable column, exactly what happens to its NULL rows and why that's the intended behavior.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1031\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}