在mysql数据库中我有一个表:
+---------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+----------------+
| user_id | int(20) unsigned | NO | PRI | NULL | auto_increment |
| NAME | varchar(20) | YES | | NULL | |
| email | varchar(20) | NO | PRI | | |
+---------+------------------+------+-----+---------+----------------+
我有数据:
+---------+--------+------------------+
| user_id | NAME | email |
+---------+--------+------------------+
| 1 | ap | aa1@aol.com |
| 3 | as | aap@aol.com |
| 4 | salini | salini@gmail.com |
+---------+--------+------------------+
现在我的要求: 我想一次删除并设置一行的值..
假设我要删除名称并更新email='saliniRoy@gmail.com,其中name = salini
所以我正在使用
UPDATE student
SET email='saliniRoy@gmail.com' & delete name
WHERE name=salini;
但它不起作用......我必须做什么呢?
答案 0 :(得分:3)
您必须将名称设置为空白:
UPDATE student
SET email='saliniRoy@gmail.com', name=''
WHERE name='salini';
或null
UPDATE student
SET email='saliniRoy@gmail.com', name=null
WHERE name='salini';