SELECT * FROM Table WHERE Field IS NULL
, SQL, , - . NULL -. NULL - , . NULL . NULL , ( SQL) , . . - SQL .
[ NOT ] LIKE [] . % () , _ () .
SELECT * FROM Employees WHERE Name LIKE %
:
SELECT * FROM Employees WHERE Name LIKE __%
:
[NOT] IN [] :
SELECT * FROM Employees WHERE Position IN (, )
[ NOT ] BETWEEN [] :
SELECT * FROM Employees WHERE Salary BETWEEN 200 AND 500
, 200 .. 500 ..
AND, OR NOT:
SELECT *
FROM Employees
WHERE Position IN (, )
AND Salary BETWEEN 200 AND 500
SELECT *
FROM Employees
WHERE (Position = OR Position =
)
AND Salary BETWEEN 200 AND 500
SELECT *
FROM Employees
WHERE NOT (Position = OR Position =
)
ORDER BY
ORDER BY SELECT . :
ORDER BY Field1 [ASC | DESC] [, Field2 [ASC | DESC] ] [, ]
ASC , DESC . ASC DESC , ASC. , :
SELECT *
FROM Employees
WHERE Position =
ORDER BY Salary DESC
( ) ( ):
SELECT *
FROM Employees
ORDER BY DeptNum ASC, Salary DESC
ASC , :
SELECT *
FROM Employees
ORDER BY DeptNum, Salary DESC
, , . :
|
|
SUM(Field) | |
MIN(Field) | |
MAX(Field) | |
AVG(Field) | |
COUNT(*) | |
COUNT(Field) |
, , , :
SELECT MAX (SALARY)
FROM Employees
:
SELECT COUNT (*)
FROM Employees
GROUP BY
, , . , GROUP BY:
GROUP BY Field1 [, Field2] [, ]
, :
SELECT DeptNum, MAX (SALARY)
FROM Employees
GROUP BY DeptNum
MAX DeptNum.
HAVING
HAVING. , 1000 ..:
SELECT DeptNum, MAX (SALARY)
FROM Employees
GROUP BY DeptNum
HAVING MAX (SALARY) > 1000
, HAVING WHERE . WHERE , , GROUP BY. HAVING.
:
- ;
- ;
- .
INSERT
INSERT. :
INSERT INTO < > [(< >)]
VALUES (< >)
, :
INSERT INTO Employees(TabNum, Name, Position, DeptNum,
Salary)
VALUES (45, , , 15, 850)
Employees :
Employees | ||||
TabNum | Name | Position | DeptNum | Salary |
. | ||||
. |
- (NULL):
INSERT INTO Employees(TabNum, Name, DeptNum, Salary)
VALUES (45, , 15, 850)
Employees :
Employees | ||||
TabNum | Name | Position | DeptNum | Salary |
. | ||||
VALUES . INSERT , VALUES , . :
|
|
INSERT INTO Employees VALUES (45, ,
, 15, 850)
:
INSERT INTO Employees VALUES (45, , 15, 850)
, .
NULL. :
INSERT INTO Employees VALUES (45, , NULL, 15, 850)
Position . , :
INSERT INTO Employees(TabNum, Name, Position, DeptNum,Salary)
VALUES (45, , NULL, 15, 850)
INSERT . :
INSERT INTO < > [(< >)]
< SELECT>
:
INSERT INTO Table1(Field1, Field2)
SELECT Field3, (Field4 + 5) FROM Table2
DELETE
DELETE:
DELETE FROM < > [ WHERE < >]
WHERE . , . WHERE SELECT DELETE .
DELETE:
DELETE FROM Employees
DELETE FROM Employees WHERE TabNum = 45
UPDATE
INSERT UPDATE:
UPDATE < >
SET < > = < >, < > =
< >,
WHERE < >]
DELETE, WHERE . . :
UPDATE Employees SET Salary = Salary + 100
UPDATE Employees
SET Position = , Salary = 1000
WHERE TabNum = 45 AND Position IS NULL