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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Frustrating simple query

Author  Topic 

adlo
Posting Yak Master

108 Posts

Posted - 2004-08-30 : 13:19:38
I have the following simple query that is giving me grey hairs.

2 tables.
Table1: Skill1 (Fields: User_ID,Skill_ID)
Table2: Skill2 (Fields: User_ID,SKill_ID)

I need to merge these two table with each other into one table SkillMerge (Fields: User_ID,SKill_ID)

E.g.
Skill1: (1,1)(1,2)(2,1)
Skill2: (2,1)(2,2)(2,3)

SkillMerge should be (1,1)(1,2)(2,1)(2,2)(2,3)

Thanks






Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-30 : 14:08:34
Union.

Select User_Id, Skill_Id From Skill1
Union Select User_Id, Skill_Id From Skill2


Corey
Go to Top of Page

adlo
Posting Yak Master

108 Posts

Posted - 2004-08-30 : 14:16:22
Thanks I have never heard of the UNION command before.

quote:
Originally posted by Seventhnight

Union.

Select User_Id, Skill_Id From Skill1
Union Select User_Id, Skill_Id From Skill2


Corey

Go to Top of Page

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2004-08-30 : 14:25:40
Was this part of a homework assignment?
Go to Top of Page

adlo
Posting Yak Master

108 Posts

Posted - 2004-08-30 : 14:42:01
No, just me not knowing all my SQL server functions.
I tried to do it with selects and inner joins and really struggled.
Stupid me.
Go to Top of Page
   

- Advertisement -