如何用空值更新列 [英] How to update column with null value

查看:56
本文介绍了如何用空值更新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mysql,需要用空值更新一列.我已经尝试了许多不同的方法,而我得到的最好的结果是一个空字符串.

I am using mysql and need to update a column with a null value. I have tried this many different ways and the best I have gotten is an empty string.

有特殊的语法可以做到这一点吗?

Is there a special syntax to do this?

推荐答案

无特殊语法:

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)

这篇关于如何用空值更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆