NULL or Empty String in SQL
Level 368 keystrokes
Lists the customers whose phone is missing: IS NULL finds rows with no value at all and = '' finds empty strings, and OR combines both checks, so Alice (NULL) and Bob ('') are returned.
SQL code
1SELECT -- Returns the name and phone columns2 name,3 phone4FROM -- Reads from the customers table5 customers-- WHERE keeps only rows with a missing phone6WHERE -- IS NULL matches no value at all (Alice); phone = NULL would never be true7 phone IS NULL -- OR also matches the empty string '' (Bob), which is a value, not NULL8 OR phone = '';Output
+-------+-------+ | name | phone | +-------+-------+ | Alice | NULL | | Bob | | +-------+-------+ 2 rows in set
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this SQL code and how often they appear.
'× 2,× 1;× 1=× 1