表full中userID和movieID两个字段确定一条唯一的数据。
现在表中有少量重复数据和大量非重复数据。
重复数据中,preference列和timestamp列不为空的这些,需要保留;preference列和timestamp列为空的这些需要删除,应该怎么办?+------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------+------+-----+---------+-------+
| userID | int(11) | NO | | 0 | |
| movieID | int(11) | NO | | 0 | |
| preference | int(11) | YES | | NULL | |
| timestamp | int(11) | YES | | NULL | |
+------------+---------+------+-----+---------+-------+初学者,希望答案详细:) 感激不尽

解决方案 »

  1.   

    举例说明 
    delete from tt where preference is null and timestamp is null
      

  2.   

    有大量的、需要保留的、非重复数据的这两列也是空的,想要删除重复的、这两列为空的数据。我觉得需要个if条件什么的……但是mysql里不知道该怎么写
      

  3.   

    delete from 表 where preference is null and timestamp is null