January 16, 2008 at 3:01 am
Hi
what is the diff b/w UNION and JOIN .Please explain with examples
Binu
January 16, 2008 at 3:15 am
Books online has good info on both. Or, if you don't have books online, the online technet library
Join fundamentals: http://technet.microsoft.com/en-us/library/ms191517.aspx"> http://technet.microsoft.com/en-us/library/ms191517.aspx
Union: http://technet.microsoft.com/en-us/library/ms180026.aspx%5B/url%5D
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 16, 2008 at 4:21 am
UNION - Combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union. The UNION operation is different from using joins that combine columns from two tables.
For eg:
select_statement UNION [ALL] select_statement
JOINS - By using joins, you can retrieve data from two or more tables based on logical relationships between the tables.
For eg:
select * from table1 A JOIN table2 B ON A.Some_ID=B.Some_ID
SOURCE: BOL
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply