Click here to Skip to main content
15,899,026 members
Home / Discussions / Database
   

Database

 
GeneralRe: whats the proper defination of view Pin
ToddHileHoffer9-Mar-05 10:25
ToddHileHoffer9-Mar-05 10:25 
GeneralRe: whats the proper defination of view Pin
Colin Angus Mackay9-Mar-05 13:32
Colin Angus Mackay9-Mar-05 13:32 
GeneralRe: whats the proper defination of view Pin
Yulianto.9-Mar-05 14:32
Yulianto.9-Mar-05 14:32 
GeneralRe: whats the proper defination of view Pin
Colin Angus Mackay9-Mar-05 14:53
Colin Angus Mackay9-Mar-05 14:53 
Generalit is givi ng me syntax error Pin
feeha9-Mar-05 7:37
feeha9-Mar-05 7:37 
GeneralRe: it is givi ng me syntax error Pin
ToddHileHoffer9-Mar-05 8:32
ToddHileHoffer9-Mar-05 8:32 
GeneralRe: it is givi ng me syntax error Pin
feeha9-Mar-05 9:26
feeha9-Mar-05 9:26 
GeneralQuestion on UNION syntax Pin
KreativeKai9-Mar-05 6:06
professionalKreativeKai9-Mar-05 6:06 
I'm new to SQL and trying to understand what is most likely a simple question.

I'm trying to use UNION to pull together a result set of Name and Employee Number. Unfortunately there are duplicates in the two tables. The UNION syntax is supposed to weed out duplicates, but I have this situation.

First Name Last Name ID
TOM JONES 1111
TOM L JONES 1111

The code below shows what I have. The UNION evidentally looks at all the fields you bring back with the select. I need it to UNION only on the EmpID, but also have the name in the result list. I don't care which table it pulls the name, because either way, the name should be basically alike.

SELECT LastName,FirstName,EmpNo AS EmpID
FROM table1
WHERE EmpTermDate IS NULL
UNION
SELECT LastName, FirstName, SocSecNo AS EmpID
FROM table2
ORDER BY LastName ASC,FirstName ASC, EmpID ASC

Any suggestions how to UNION the information while eliminating duplicates based on EmpID only? Any help is appreciated!! Confused | :confused:

Lost in the vast sea of .NET
GeneralRe: Question on UNION syntax Pin
ToddHileHoffer9-Mar-05 8:35
ToddHileHoffer9-Mar-05 8:35 
GeneralRe: Question on UNION syntax Pin
Edbert P9-Mar-05 13:11
Edbert P9-Mar-05 13:11 
GeneralRe: Question on UNION syntax Pin
KreativeKai10-Mar-05 4:25
professionalKreativeKai10-Mar-05 4:25 
GeneralRe: Question on UNION syntax Pin
Edbert P10-Mar-05 15:36
Edbert P10-Mar-05 15:36 
GeneralRe: Question on UNION syntax Pin
KreativeKai11-Mar-05 3:15
professionalKreativeKai11-Mar-05 3:15 
GeneralTrancation Replication Problems Pin
tyaramis9-Mar-05 0:19
tyaramis9-Mar-05 0:19 
GeneralDBF Export from SQL server Pin
davethiss9-Mar-05 0:06
davethiss9-Mar-05 0:06 
GeneralHow Pin
Yulianto.8-Mar-05 17:46
Yulianto.8-Mar-05 17:46 
GeneralRe: How Pin
Yulianto.8-Mar-05 18:07
Yulianto.8-Mar-05 18:07 
GeneralRe: How Pin
ToddHileHoffer9-Mar-05 8:38
ToddHileHoffer9-Mar-05 8:38 
Questionhow to create a view in sql Pin
feeha8-Mar-05 9:10
feeha8-Mar-05 9:10 
AnswerRe: how to create a view in sql Pin
Chris Meech8-Mar-05 9:34
Chris Meech8-Mar-05 9:34 
AnswerRe: how to create a view in sql Pin
Anonymous10-Mar-05 0:26
Anonymous10-Mar-05 0:26 
Questionhow to save pic Pin
javad_20058-Mar-05 7:05
javad_20058-Mar-05 7:05 
AnswerRe: how to save pic Pin
ToddHileHoffer8-Mar-05 7:28
ToddHileHoffer8-Mar-05 7:28 
GeneralNeed a Help Pin
Anonymous8-Mar-05 5:42
Anonymous8-Mar-05 5:42 
GeneralRe: Need a Help Pin
Chris Meech8-Mar-05 5:51
Chris Meech8-Mar-05 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.