The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> Database Management
|
merging records
Discuss merging records in the Database Management forum on Dev Shed. merging records Database Management forum discussing non-database specific SQL. Structured Query Language was designed to be a robust and standardized language for manipulating relational databases.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 4th, 2002, 02:42 PM
|
|
Junior Member
|
|
Join Date: Mar 2002
Posts: 4
Time spent in forums: < 1 sec
Reputation 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 02:50 PM.
|

March 5th, 2002, 12:50 AM
|
|
Contributing User
|
|
Join Date: Jul 2001
Location: Oslo
Posts: 1,516

Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
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
|

March 5th, 2002, 07:09 AM
|
|
Junior Member
|
|
Join Date: Mar 2002
Posts: 4
Time spent in forums: < 1 sec
Reputation 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 07:12 AM.
|

March 5th, 2002, 08:56 AM
|
|
Contributing User
|
|
Join Date: Jul 2001
Location: Oslo
Posts: 1,516

Time spent in forums: < 1 sec
Reputation Power: 13
|
|
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 
|

March 5th, 2002, 09:06 AM
|
|
Junior Member
|
|
Join Date: Mar 2002
Posts: 4
Time spent in forums: < 1 sec
Reputation 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.
|

March 5th, 2002, 09:29 AM
|
|
Contributing User
|
|
Join Date: Jul 2001
Location: Oslo
Posts: 1,516

Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
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.
|

March 11th, 2002, 02:09 PM
|
|
Gödelian monster
|
|
Join Date: Jul 1999
Location: Central Florida, USA
|
|
|
What kind of database are you using? MySQL? PostgreSQL? MSSQL? Others?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|