Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    3

    Question Unanswered: making 2 fields as primary keys

    does anyone happen to know how to remove duplicates of 2 fields instead of 1 field? the record removed should be of an earlier date registered.

    eg.
    s/no - 12345 model no - 4433 date - 12/25/03
    s/no - 12345 model no - 4433 date - 10/23/03
    s/no - 12345 model no - 4442 date - 10/21/03

    in this case, only the 2nd field will be removed..

  2. #2
    Join Date
    Jun 2003
    Posts
    21

    Re: making 2 fields as primary keys

    Originally posted by sky07
    does anyone happen to know how to remove duplicates of 2 fields instead of 1 field? the record removed should be of an earlier date registered.

    eg.
    s/no - 12345 model no - 4433 date - 12/25/03
    s/no - 12345 model no - 4433 date - 10/23/03
    s/no - 12345 model no - 4442 date - 10/21/03

    in this case, only the 2nd field will be removed..
    what is it exactly that you want...you're subject doesn't really make sense looking at the rest of the message...not to me atleast...

    If you want to remove double values like in the above example and the most recent record should be saved, do something like:

    DELETE * FROM your_table WHERE id NOT in (SELECT TOP 1 FROM your_table GROUP BY serial_number ORDER BY date)

    supposing you do have a id column in your table.

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    are you trying to remove a field or a row?

    And if it is a field do you mean update it?

Posting Permissions

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