Query to find duplicate item in 2 table

Posted by Rico on Stack Overflow See other posts from Stack Overflow or by Rico
Published on 2010-12-28T13:40:05Z Indexed on 2010/12/30 2:53 UTC
Read the original article Hit count: 174

Filed under:
|
|

I have this table

Antecedent           Consequent
I1                   I2                   
I1                   I1,I2,I3
I1                   I4,I1,I3,I4
I1,I2                I1
I1,I2                I1,I4
I1,I2                I1,I3
I1,I4                I3,I2
I1,I2,I3             I1,I4
I1,I3,I4             I4

AS you can see it's pretty messed up. is there anyway i can remove rows if item in consequent exist in antecedent (in 1 row)

for example: INPUT:

Antecedent           Consequent
I1                   I2                   
I1                   I1,I2,I3    <---- DELETE since I1 exist in antecedent
I1                   I4,I1,I3,I4 <---- DELETE since I1 exist in antecedent
I1,I2                I1          <---- DELETE since I1 exist in antecedent
I1,I2                I1,I4       <---- DELETE since I1 exist in antecedent
I1,I2                I1,I3       <---- DELETE since I1 exist in antecedent
I1,I4                I3,I2       
I1,I2,I3             I1,I4       <---- DELETE since I1 exist in antecedent
I1,I3,I4             I4          <---- DELETE since I4 exist in antecedent

OUTPUT:

Antecedent           Consequent
I1                   I2  
I1,I4                I3,I2            

is there anyway i can do that by query?

© Stack Overflow or respective owner

Related posts about sql

Related posts about query