MySQL Forums
Forum List  »  Newbie

Re: Delete in IF or CASE function
Posted by: Vemsom Helst
Date: June 29, 2017 07:24AM

Hi!

Hmmm I'm not sure I get what you mean with ...x=y... The base deleteion either. But if I understand you correct the base deletion I'm after is:

-All rows that are duplicates but where column signal_id has value 0 or 1 (all column values being the same in the duplicate rows except for signal_id, who is causing duplicate rows). If there exist a duplicate and has signal_id in 1 and 0, remove row with 0. Otherwise keep.

So I don't know what x=y is in your example. I did write and test this one, but get error:

delete from tab
where SIGNAL_ID=0
and SIGNAL_ID=(SELECT a.orders, a.y, a.SIGNAL_ID
FROM tab a
INNER JOIN tab b ON a.orders = b.orders
WHERE a.SIGNAL_ID <> b.SIGNAL_ID);
The subquery resulted in all duplicate rows with 1 and 0.

http://sqlfiddle.com/#!9/a4a3b/29

Options: ReplyQuote


Subject
Written By
Posted
Re: Delete in IF or CASE function
June 29, 2017 07:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.