Re: SQL UNION Question (or not UNION?)



<johnrou@xxxxxxxxxxxxxxxxxx> wrote in message
news:1165861376.324576.246770@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<cut>
SELECT DISTINCT Last_Name as LName, First_Name as FName, Middle_Name
as MName From Table1 UNION SELECT DISTINCT LastName as LName,
FirstName as FName, MiddleName as MName From Table2

Works great except I can't tell which table it came from.... any help
is appreciated....


SELECT DISTINCT Last_Name as LName, First_Name as FName, Middle_Name
as MName,1 as FromTable From Table1
UNION
SELECT DISTINCT LastName as LName,
FirstName as FName, MiddleName as MName, 2 as FromTable From Table2

Note that if you have duplicates across the tables you'll now see both of
them since the 'fromtable' field will be different

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

.



Relevant Pages

  • RE: Leading blanks being stripped
    ... FullName - FName, MName, LName ... FormalName - Prefix, FName, MName, LName, Degrees ...
    (microsoft.public.access.forms)
  • SQL UNION Question (or not UNION?)
    ... SELECT DISTINCT Last_Name as LName, First_Name as FName, Middle_Name as ... MName From Table1 UNION SELECT DISTINCT LastName as LName, ... FName, MiddleName as MName From Table2 ...
    (microsoft.public.vb.database)
  • Re: Create Table?
    ... Lyle Fairfield wrote: ... I have a table that has the following fields; LName, FName and ... MName. ...
    (comp.databases.ms-access)
  • Re: Create Table?
    ... DFS wrote: ... I have a table that has the following fields; LName, FName and MName. ...
    (comp.databases.ms-access)
  • Re: Help with SQL - Update between tables
    ... In English what I want to do is set the fname and lname of table1 to ... that of table2 where the emplid's match ... update table1 A set ...
    (comp.databases.oracle.misc)

Loading