Home > Database Management > merging records

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.

    
Guest


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?

Was this answer helpful ? Yes No   
Guest


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.

Was this answer helpful ? Yes No   
Guest


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

Was this answer helpful ? Yes No   
Guest


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.

Was this answer helpful ? Yes No   
Guest


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.

Was this answer helpful ? Yes No   
Guest


What kind of database are you using? MySQL? PostgreSQL? MSSQL? Others?

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2010 by Infoqu. All rights reserved