我需要从我的表中删除重复项,但MySQL的工作不正常MySQL中,删除重复的
Create table emp
(empID INT(5) PRIMARY KEY,
Pref01 int(1),
Pref02 int(1),
Pref03 int(1),
Pref04 int(1))
empID, Pref01, Pref02, Pref03, Pref04 ===================================== 00011 1 2 0 0 00011 1 3 0 0 00022 1 1 0 0 00022 0 3 0 0
我需要保持这些记录
00011 1 3 0 0 00022 0 3 0 0
也是我需要保持任何记录所有pref空值 这是我的sql:
select empID
FROM emp
where max(Pref01) or max (Pref02) or max(Pref03) or max(Pref04)
or Pref01 is null or Pref02 is null or Pref03 is null or Pref04 is null
个
'max(Pref01)'不是一个布尔表达式。这可能不会达到你的期望。 –
另外...在问题中不清楚你是如何知道为给定的empID保留哪条记录的。什么是决定这个的规则? –
我需要保留记录与最大普雷夫编号 – Niloo