Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2015
    Posts
    2

    Unanswered: Removing duplicates but not all of them

    Hi guys, help me please otherwise i will hang myself :P

    I have two tables
    -> Products
    id | code | offer | email | method | revoked
    1, 12, 30, a@a.com, paypal, 0
    2, 14, 30, a@b.com, warrior, 0
    3, 12, 30, a@a.com, paypal, 0
    4, 12, 30, a@a.com, manual, 0
    5, 12, 30, a@a.com, paypal, 0

    -> Activations
    id | product | date
    1, 3, 215-05-06

    As you can see in Activations there's a column 'product' that references to 'id' in products table.
    Some products have, some might have not any activations

    As you can see in Products table there are 3 duplicated entries (same: code,offer,email,method) but one of them is activated (3).

    Now what i try to achive and failed like a million times:
    -> find duplicated values
    -> if duplicated entry exists in activations do nothing
    -> if it does not exists in activations then set revoke = 1

    but if there's let's say 5 duplicated values, we need to set revoke to 4 of them leaving one with value = 0. Analogically if there's one or more activated we need to set all not activated to revoke = 0

    Any ideas ?:P

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Which one of the 5 gets to stay with revoked=0?
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by gvee View Post
    Which one of the 5 gets to stay with revoked=0?
    my thoughts exactly, especially as there is only one product (ID = 3) with an activation.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jul 2015
    Posts
    2
    In above example only product with id = 3 because it has activation, but also product 4 because it doesnt have aby duplicates.

    Theres also a condition where we have 10 product, not a single one is activated, so 9 should be revoked, but one needs to stay.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •