Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

database - Update a double type column with NULL value in mysql

I have the following table:

IDCode(bigint(20)) lng(double)
0000 NULL
NULL NULL
0000 NULL
0000 NULL
NULL NULL
0000 NULL

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Why do you want to use ''?

You can just simply update the data without using ''.

i.e :

UPDATE profile SET lng = 1 WHERE IDCode IS NOT NULL;

This is the code I have tested on : https://paiza.io/projects/PWQZ8UXjGN6KDnMiFfXaKQ?language=mysql

create table profile(IDCode bigint(20), lng double);
insert into profile values(null, null);
insert into profile values(null, null);
insert into profile values(null, null);
insert into profile values(null, null);
insert into profile values(0000, null);
insert into profile values(0000, null);

UPDATE profile SET lng = 1 WHERE IDCode IS NOT NULL;
select * from profile;

Result

IDCode  lng
NULL    NULL
NULL    NULL
NULL    NULL
NULL    NULL
0   1
0   1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...