DBMS U-4
DBMS U-4
Advanced SQL
Set Operators
SET operators are special type of operators which are used to combine
the result of two queries.
Operators covered under SET operators are:
• UNION
• UNION ALL
• INTERSECT
• MINUS
• We want to see the people who are both our friend and our
connection.
• So in this case it would only be Matt. Let's now query using a variety
of defining the JOIN condition.
All three of these queries produce the same correct result:
SELECT *
FROM facebook
JOIN linkedin
ON facebook.name = linkedin.name
SELECT *
FROM facebook
JOIN linkedin
WHERE facebook.name = linkedin.name
SELECT *
FROM facebook, linkedin
WHERE facebook.name = linkedin.name
• The first two are types of explicit joins and the last is an implicit join.
• An explicit JOIN explicitly tells you how to JOIN the data by
specifying the type of JOIN and the join condition in the ON clause.
• An Implicit JOIN does not specify the JOIN type and use the WHERE
clause to define the join condition.
Outer joins:
Outer joins are joins that return matched values and
unmatched values from either or both tables. There A B
Example:
SELECT NOW () AS Current_Date_Time;
The following table lists the most important built-in
date functions in SQL Server:
Function Description
3 EXP() The EXP() function returns e raised to the power of a specified number.
4 FLOOR() The FLOOR() function returns the largest integer value that is smaller than or equal to a
number. [SELECT FLOOR(25.75) AS FloorValue; 25]
ASCII Returns the ASCII value for the specific NCHAR Returns the Unicode character based on
character the number code
CHAR Returns the character based on the ASCII REVERSE Reverses a string and returns the result
code
RIGHT Extracts a number of characters from a
CONCAT Adds two or more strings together
string (starting from right) [SELECT RIGHT("SQL
LEFT Extracts a number of characters from a Tutorial is cool", 4) AS ExtractString;]
string (starting from left) [SELECT LEFT('SQL
Tutorial', 3) AS ExtractString;] RTRIM Removes trailing spaces from a string