You are on page 1of 7

Section 2

Concatenation
• means to connect or link together in a series
The syntax is:
string1 || string2 || '123' || string_n

• When values are concatenated, the resulting


value is a character string.
Concatenation and Column Aliases
• Column aliases are useful when using the
concatenation operator so that the default
SELECT line does not appear as the column
heading.
SELECT first_name ||' '||
last_name AS "Employee Name"
FROM employees;
Using DISTINCT to Eliminate Duplicate
Rows

SELECT DISTINCT department_id


FROM employees;
Comparison Operators
• BETWEEN…AND... SELECT last_name, salary
FROM employees
the output included the WHERE salary BETWEEN
lower-limit and upper-limit values. 9000 AND 11000;

WHERE salary > 9000 AND WHERE salary >= 9000 AND
salary < 11000; salary <=11000;
• IN
The IN condition is also known as the "membership
condition."
SELECT city, state_province,
country_id WHERE country_id = 'UK'
FROM locations OR country_id = 'CA';
WHERE country_id IN('UK', 'CA');
Comparison Operators
• LIKE
• Two symbols : the (%) and the underscore (_) – called wildcard
characters, can be used to construct a search string.
• The percent (%) symbol is used to represent any sequence of zero
or more characters.
• The underscore (_) symbol is used to represent a single character.

SELECT last_name
FROM employees
WHERE last_name LIKE 'o';
IS NULL, IS NOT NULL
• The IS NULL condition tests for unavailable,
unassigned, or unknown data.
SELECT last_name, manager_id
FROM employees
WHERE manager_id IS NULL;

• IS NOT NULL tests for data that is available in the


database.

SELECT last_name, commission_pct


FROM employees
WHERE commission_pct IS NOT NULL;

You might also like