Thread: merging records

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    4
    Rep Power
    0

    merging records


    I am trying to combine 2+ records into 1, in the same table with the same id_# but different data in different columns.

    Does anyone know how to write a query to do that?
    Any help is greatly appreciated.
    Last edited by jdlux; March 4th, 2002 at 03:50 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jul 2001
    Location
    Oslo
    Posts
    1,516
    Rep Power
    15
    What do you mean by combine? I mean, are they numeric values that you want to sum? Strings you want to concatenate? Videos you want to merge?
    --
    Regards
    André Nćss

    Puritanism: The haunting fear that someone, somewhere may be having fun
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    4
    Rep Power
    0
    i mean, i am trying to take te values in one record and put them in another record.

    example:

    id age ssn
    01 022 ----
    01 ----- 333-55-2298

    given the above, i am trying to have record 1 and 2 combined to
    store 1 record.
    Last edited by jdlux; March 5th, 2002 at 08:12 AM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jul 2001
    Location
    Oslo
    Posts
    1,516
    Rep Power
    15
    Eh... in your case that's not really possible because you have no unique key from what I can see (the id is 01 in both rows). You'll have to do this by using some sort of script, but what if you have something like:
    01, NULL, 'Foo'
    01, 'Bar', NULL
    01, 'Do', NULL

    It's seems to me like you have some seriously screwed data
    --
    Regards
    André Nćss

    Puritanism: The haunting fear that someone, somewhere may be having fun
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    4
    Rep Power
    0
    thats just it though, i have no over-lapping data.
    the whole table is formatted like this.

    ID AGE SS_NUMBER
    01 022 -----------------
    01 ----- 333-55-2298
    02 033 -----------------
    02 ----- 444-55-2298
    ..........
    ..........
    ..........
    ..........
    10 044 -----------------
    10 ----- 111-22-3344

    whoever input'd (not a word is it) this data did it wrong and i have to try 'TRY' and fix it.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jul 2001
    Location
    Oslo
    Posts
    1,516
    Rep Power
    15
    Well, then doing it in a script (e.g. PHP) is your only chance. This sort of data shouldn't even be in allowed in a database.

    You'll have to extract *all* the records, merge them using the script language, then insert them in a properly designed table.
    --
    Regards
    André Nćss

    Puritanism: The haunting fear that someone, somewhere may be having fun
  12. #7
  13. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    What kind of database are you using? MySQL? PostgreSQL? MSSQL? Others?
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com

IMN logo majestic logo threadwatch logo seochat tools logo