2. Action symbols that appear in the SELECT statement
2.1 Merging Operators
Select A.ename| | ' ' | | To_char (SAL) from EMP A;
2.2 To eliminate duplicate rows
SELECT DISTINCT deptno from EMP;
2.3 The difference between a space, an empty string, and a null
Select ASCII ('), ASCII (NULL), ASCII (') from dual;
Difference:
Explicitly, an empty string is the same value stored in the database as NULL, but NULL can be assigned to any data type, whereas an empty string can only be assigned to a string type
To filter null values, you need to use the following notation
SELECT * FROM EMP where comm are NOT null;
Typical errors (but no error)
SELECT * FROM emp where comm! = NULL;
SELECT * from emp where comm <> null;
SELECT * FROM emp where comm = null;
2.4 Comparison operations
= >= <= <>! = > < in like are NULL is not null between and not between and
SELECT * from EMP where Sal between and 1500; --Includes 800 and 1500
=
SELECT * from emp where Sal >= and sal<= 1500;
SELECT * from emp where Sal is not between and 1500;
=
SELECT * from emp where Sal < n or sal > 1500;
SELECT * from EMP where empno in (7499,7698,7788);
=
SELECT * from emp where empno=7499 or empno=7698 or empno=7788;
SELECT * from emp where ename like ' t% ';
SELECT * from emp where ename ' t% ';
SELECT * from emp where ename like '%t% ';
SELECT * from emp where ename '%t% ';
SELECT * from emp where sal! = 1000
=
SELECT * from emp where Sal <> 1000
2.5 Logical operators
Boolean operation (Boolean) evaluates to: TRUE, FALSE
Non-OR and
And
True and false = False
True and True = True
Flase and false = False
Or
True or false = True
True or True = True
Flase or false = False
Non -
Not true = False
Not false = True
SELECT * from emp where sal! = job= ' clerk '
SELECT * from emp where sal! = or job= ' clerk '
Attention:
Order of precedence issues:
Not > and > OR If you want to override the default priority order, you have to use parentheses
SELECT * from emp where not (job= ' Saleman ' or job= ' clerk ') and Sal > 1000
SELECT * from emp where not job= ' Saleman ' or job= ' clerk ' and sal > 1000
The action symbol that appears in the SQL Base statement-select statement