我在E/AndroidRuntime: FATAL EXCEPTION: main
Process: fr.pinty, PID: 24751
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {fr.pinty/fr.pinty.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Fragment.onActivityResult(int, int, android.content.Intent)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4089)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Fragment.onActivityResult(int, int, android.content.Intent)' on a null object reference
at fr.pinty.MainActivity.onActivityResult(MainActivity.java:92)
at android.app.Activity.dispatchActivityResult(Activity.java:6932)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4085)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
中有一个查询,根据该查询我找到了一些列的重复记录。
MySQL
以上查询为我提供select max(id), count(*) as cnt
from table group by start_id, end_id, mysqltable
having cnt>1;
以及max(id)
列值相同的记录数量。
我想删除与上述查询的start_id,end_id,mysqltable
列匹配的所有记录
我该怎么做?
我试过以下
max(id)
但无法删除记录
答案 0 :(得分:1)
您可以使用JOIN删除重复记录。
DELETE t1 FROM table t1
INNER JOIN
table t2
WHERE
t1.id > t2.id AND t1.start_id = t2.start_id AND t1.end_id = t2.end_id AND t1.mysqltable = t2.mysqltable;
此查询保留最低ID并删除最高ID。
答案 1 :(得分:1)
我认为这个命令应该有效:
delete from table
where id in
( select max(id) from table
group by start_id, end_id, mysqltable
having count(*) > 1
);