SQL UNION - Overview, syntax

          

SQL UNION


SQL UNION - Introduction and syntax

<<Previous  Next>>

SQL Union - Dec 03, 2008 at 18:00 PM by Rajmeet Ghai

Explain the SQL UNION statement. Write SQL syntax for the SQL UNION statement along with an example.

SQL UNION: The UNION operator is used to combine the result-set of two or more SELECT statements Tables of both the select statement must have the same number of columns with similar data types. It eliminates duplicates.

Syntax:
SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2

Example:
SELECT emp_Name FROM Employees_india UNION SELECT emp_Name FROM Employees_USA

SQL Union - May 18, 2009 at 10:00 AM by Rajmeet Ghai

What is the difference between UNION and UNION ALL?

UNION command selects distinct and related information from two tables. On the other hand, UNION ALL selects all the values from both the tables.


<<Previous  Next>>

Also read

List out the difference between CUBE operator and ROLLUP operator

Answer - CUBE generates a result set that represents aggregates for all combinations of values in the selected columns....... 

What are the ways to code efficient transactions?

Answer - Database users can have permission to execute a stored procedure without being....

What are the events recorded in a transaction log?

Answer - The start and end of each transaction......  

Define transaction and transaction isolation levels.

Answer - A transaction is a set of operations that works as a single unit. The ransactions can be categorized into explicit, autocommit, and implicit....

Define temporary and extended stored procedure.

Answer - Temporary Stored Procedure is stored in TempDB database. It is volatile and is deleted once connection gets terminated or server is restarted......

Define Primary and Unique key.

Answer - The column or columns of the table whose value uniquely identifies each row in the table is called primary key. You can define column as primary key using primary key constraint while you create table.....

What is index? Define its types.

Answer - Index can be thought as index of the book that is used for fast retrieval of information. Index uses one or more column index keys and pointers to the record to locate record.........



Write your comment - Share Knowledge and Experience


 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring