SQL >> Database >  >> RDS >> Mysql

Een MySQL-kolom op NULL zetten

Goed nieuws: er is geen speciale syntax voor nodig. Je wijst in je UPDATE gewoon NULL toe, en je controleert daarna met IS NULL in plaats van het gelijkteken.

CREATE TABLE your_table (some_id int, your_column varchar(100)); INSERT INTO your_table VALUES (1, 'Hello'); UPDATE your_table SET your_column = NULL WHERE some_id = 1; SELECT * FROM your_table WHERE your_column IS NULL; +---------+-------------+ | some_id | your_column | +---------+-------------+ | 1 | NULL | +---------+-------------+ 1 row in set (0.00 sec) 

De kern: NULL betekent “onbekend”, dus test je erop met IS NULL en nooit met = NULL.

  1. Oracle-kolommen bijwerken waar waarden NULL zijn

  2. Een kolom in MySQL bijwerken met Excel

  3. Een MySQL-kolom op NULL zetten in een UPDATE

  4. Hoe een unique constraint werkt met een NULL-waarde in MySQL