0% found this document useful (0 votes)
44 views1 page

The SQL UNION Operator

The document discusses three SQL statements: UNION combines result sets from SELECT statements if columns match; GROUP BY groups rows by column values; EXISTS returns true if a subquery returns any records.

Uploaded by

Abdul Razzak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

The SQL UNION Operator

The document discusses three SQL statements: UNION combines result sets from SELECT statements if columns match; GROUP BY groups rows by column values; EXISTS returns true if a subquery returns any records.

Uploaded by

Abdul Razzak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

The SQL UNION Operator

This operator is used in order to combine the result set of two or more SELECT statement. The columns
in each SELECT statement should be in same order. They should have similar data types and statements
within UNION must have same number of columns.
UNION Syntax:

SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
UNION ALL Syntax:

SELECT column_name(s) FROM table1
UNION ALL
SELECT column_name(s) FROM table2;

The SQL GROUP BY Statement


This statement makes groups of rows that contains the same values in summary rows.
GROUP BY Syntax:

SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);

The SQL EXISTS Operator


In order to test the existence of any record, the SQL EXIST operator is very useful. It returns true if the
sub query returns one or more record.
EXISTS Syntax:

SELECT column_name(s)
FROM table_name
WHERE EXISTS
(SELECT column_name  FROM table_name WHERE condition);

You might also like