原表:
DROP TABLE IF EXISTS `sales`;
CREATE TABLE `sales` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `fruit` varchar(32) DEFAULT NULL,
  `amount` decimal(10,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
INSERT INTO `sales` VALUES ('1', 'apple', '13');
INSERT INTO `sales` VALUES ('2', 'orange', '2');
INSERT INTO `sales` VALUES ('3', 'pear', '19');
INSERT INTO `sales` VALUES ('4', 'banana', '4');
INSERT INTO `sales` VALUES ('5', 'cherry', '124');
INSERT INTO `sales` VALUES ('6', 'plum', '23');
要求:删除表中apple后面的13(就删除这一个单元格,apple这一行其它数据还保留),请问用什么语句。

解决方案 »

  1.   

    首先纠正一下你的称谓 那个不叫单元格 放在excel等表格软件中才叫单元格
    他的正确叫法是字段(field) 
    你的要求是使用update 对该字段内容进行更新
    可以使用update语句来完成
    置于update语句怎么来完成请参考sql大全
      

  2.   

    是替换,UPDATE `sales` SET `amount`=0 WHERE ID=1
      

  3.   

    update sales set amount is null where fruit='apple';
      

  4.   

    mysql> select * from sales;
    +----+--------+--------+
    | id | fruit  | amount |
    +----+--------+--------+
    |  1 | apple  |     13 |
    |  2 | orange |      2 |
    |  3 | pear   |     19 |
    |  4 | banana |      4 |
    |  5 | cherry |    124 |
    |  6 | plum   |     23 |
    +----+--------+--------+
    6 rows in set (0.06 sec)mysql> alter table sales drop column amount;
    Query OK, 6 rows affected (0.15 sec)
    Records: 6  Duplicates: 0  Warnings: 0mysql> select * from sales;
    +----+--------+
    | id | fruit  |
    +----+--------+
    |  1 | apple  |
    |  2 | orange |
    |  3 | pear   |
    |  4 | banana |
    |  5 | cherry |
    |  6 | plum   |
    +----+--------+
    6 rows in set (0.01 sec)mysql>
      

  5.   

    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
    http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
    http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html8、如何给分和结贴?
    [url=http://community.csdn.net/Help/HelpCenter.htm#结帖]
      

  6.   

    删除单元格就是把这个单元格数据设置为null