Advertisement

07.16.2007 at 10:31PM PDT, ID: 22700605
[x]
Attachment Details

SQL - Merging fields from two tables into one, skipping duplicates

Asked by shacho in PostgreSQL Database, Oracle Database, MySQL

Tags: sql, two, tables, one, merge

I have two tables, A and B.
A has two fields, KEY_A and VAL_A.
B has two fields, KEY_B and VAL_B.
Values in KEY_A and KEY_B may overlap.

I want to select all records from A and B into a new table, C with Fields KEY_C and VAL_C.  This means I need to combine the values of KEY_A and KEY_B into one field (KEY_C), weeding out the duplicates.  How can I do this?

Mike

Start Free Trial
[+][-]07.16.2007 at 11:35PM PDT, ID: 19502568

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2007 at 11:48PM PDT, ID: 19502615

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2007 at 11:51PM PDT, ID: 19502631

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PostgreSQL Database, Oracle Database, MySQL
Tags: sql, two, tables, one, merge
Sign Up Now!
Solution Provided By: prasanthi_k
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.17.2007 at 12:06AM PDT, ID: 19502691

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.17.2007 at 12:48AM PDT, ID: 19502834

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.30.2007 at 06:58PM PDT, ID: 19597282

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32