SQLinsertInto Whereclause
SQLinsertInto Whereclause
Inside a table, a column often contains many duplicate values; and sometimes
you only want to list the different (distinct) values.
WHERE Syntax:
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Example:
SELECT name, age
FROM person
WHERE where id =1;
Operators in The WHERE Clause
The following operators can be used in the WHERE clause:
Operator Description
= Equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
<> Not equal. Note: In some versions of SQL this operator may be
written as !=
BETWEEN Between a certain range
LIKE Search for a pattern
IN To specify multiple possible values for a column
SQL ALIASES
SQL ALIASES
SQL aliases are used to give a table, or a column in a table, a temporary name.
SELECT column_name AS alias_name
FROM table_name;
SQL MIN() and MAX() Functions
The MIN() function returns the smallest value of the selected column.
The MAX() function returns the largest value of the selected column.
IN Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...);
SQL BETWEEN Operator
The BETWEEN operator selects values within a given range. The values can be numbers, text, or
dates.
The BETWEEN operator is inclusive: begin and end values are included.
BETWEEN Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
SQL ALIASES
SQL ALIASES
SQL ALIASES
The SQL INSERT INTO Statement
The INSERT INTO statement is used to insert new records in a
table.
Example:
INSERT INTO personTBL
VALUES (123, “joel”, 26, “koronadal”);
The SQL UPDATE Statement
The UPDATE statement is used to modify the existing
records in a table.
UPDATE Syntax:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Example:
UPDATE person
SET name = “jay-r”, address = “banga”
WHERE id=1;
The SQL DELETE Statement
The DELETE statement is used to delete existing records in a
table.
DELETE Syntax:
DELETE FROM table_name WHERE condition;
Example:
DELETE FROM person WHERE id = 123;