Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Merging 2 tables with different field names

Author  Topic 

yidrasil
Starting Member

21 Posts

Posted - 2011-07-28 : 16:36:04
Folks,

I have 2 tables A & B. 1 field contains the same information (key field) but the Field Names are different.

So there is no shared field name between the 2 but there is shared content.

Is it possible to merge the 2 using the column with the same content (but different name)?

Thanks for any help.......

Yid

SalasJ
Starting Member

15 Posts

Posted - 2011-07-28 : 16:56:22
You could use a JOINT command to display data from two tables or more using different fields
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-07-28 : 20:37:43
Every SQL forum or newsgroup expects that you will post DDL, sample data and clear specifications which might might include output. This is explained in the FAQ section. We can not read minds; what would we need to know to do your job for you?

Tables must have keys and should have DRI, constraints, and all the basic features of a schema. You should know use ISO-8601 Standards for temporal data, avoid needless dialect, basic data modeling and use ISO-11179 Standards for data element names. Please tell us if you can change the DDL.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-29 : 01:18:41
column name doesnt matter. you just need to join based on the column with common content. The type of join depends on whether you want only perfect match or whole records from one of table. so in effect query will be like


SELECT columns..
FROM A
{LEFT/INNER/FULL} JOIN B
ON A.keycolum = B.keycolumn


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -