Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - How do I enter NULL?

Stupid question:

In SQL, I know I can do

UPDATE TableA SET MyColumn=NULL 

But, how do I enter NULL into a cell graphically? I tried entering 'null' and 'NULL' and '' (nothing/empty string) into the MySQL Query Browser with no success.

like image 454
rlb.usa Avatar asked May 06 '10 21:05

rlb.usa


People also ask

How do you insert a NULL?

You also can specify the NULL keyword in the VALUES clause to indicate that a column should be assigned a NULL value. The following example inserts values into three columns of the orders table: INSERT INTO orders (orders_num, order_date, customer_num) VALUES (0, NULL, 123);

How do I make something NULL in SQL?

If you've opened a table and you want to clear an existing value to NULL, click on the value, and press Ctrl + 0 .

How insert NULL instead of empty string?

For example to insert NULL instead of an empty string using NULLIF() , we could do the following: INSERT INTO `user` (`name`, `job_title`) VALUES ('john', NULLIF('$jobTitle', '')); This would insert NULL in the job_title column when the value of the variable " $jobTitle " matches an empty string.

How do I insert a NULL in MySQL workbench?

You can right-click on a cell and choose "Clear Field Content" in the popup menu. It will set the cell value to NULL.


2 Answers

  1. Switch to edit mode
  2. Right click on field
  3. Choose "Clear field content"
like image 69
a1ex07 Avatar answered Sep 23 '22 17:09

a1ex07


MySQL Workbench 5.4.42: Terribly buggy, but if you try a couple of times, right-clicking the cell while in Edit mode should give you the option Set Field(s) to NULL.

DEL, Ctrl+0 or similar doesn't work.


In Workbench 6.3 the buggy UI has been fixed. Don't forget to click the Apply button to actually execute the resulting UPDATE statement.

like image 33
Gruber Avatar answered Sep 23 '22 17:09

Gruber