Unions and Joins

melissafvoelker

Registered User.
Local time
Yesterday, 17:44
Joined
Nov 1, 2005
Messages
16
I would like to know the difference between these two concepts.

Would anyone care to explain it to me?
 
Joins are tables or queries linked hortizontally. The result is all of the fields in a row.

Unions are queries linked vertically. The result is all of the records in a column.
 
huh?

okay, i kinda get it but why would someone want to do a union? Why someone would want all that data mixed up into one column is beyond me.
 
Joins compare data and selectivly add columns.

Unions take two tables with the same columns selected and make them 1 tables.

For example of union:

-Employee table with firstname, lastname, birthdate
-Dependant table with firstname, lastname, birthdate

Union the two and you have a combined table of firstname, lastname, birthdate listing all employees and dependants. The union is non relational, you would not be able to tell who is an employee and who is a dependant.
 
Neil is correct and the reasons are many but an example might be in order. Let us say for whatever reason we have two tables. On table is 'Doctors from hospital A and the other is a table of Doctors from hospital B. Someone may ask the programmer for a list of all the doctors from the 2 hospitals. A union query would provide those results. Any joins between the two tables may no be sufficient to get ALL the names but a union query is capable of this.

Sam
 

Users who are viewing this thread

Back
Top Bottom