SQL statement quick start for PHP learning _ MySQL
Source: Internet
Author: User
SQL statement quick start for PHP learning bitsCN. comSelect * from tablename
SQL> select * from employees;
Select select list from tablename
SQL> select employee_id, first_name from employees;
Select distinct... From tablename
SQL> select distinct manager_id from employees;
| Use of connectors, addition, subtraction, multiplication, division, and brackets
SQL> select employee_id, first_name | '.' | last_name, salary * (1 + 0.1)/100, manager_id
2 from employees;
+-Use the plus or minus sign
SQL> select-salary from employees;
<>,>, <, = ,! = And other comparison operators
SQL> select * from employees where salary> 13000;
SQL> select * from employees where salary <13000;
SQL> select * from employees where salary <> 13000;
SQL> select * from employees where salary = 13000;
In
SQL> select-salary from employees where employee_id in (100,101,102 );
SQL> select-salary from employees where employee_id in (select employee_id from employees );
Not in
SQL> select-salary from employees where employee_id not in (100,101,102 );
Any (more than Any one)
Select * from employees where employee_id> any (100,101,102 );
Some is the equivalent of the SQL-92 standard any
Select * from employees where employee_id> any (100,101,102 );
All (better than all)
Select * from employees where employee_id> all (100,101,102 );
Between and
Select * from employees where employee_id between 100 and 102;
Not between and
Select * from employees where employee_id not between 100 and 102;
Logical operators
And or
Select * from employees where employee_id> 100 and employee_id <1000;
Select * from employees where employee_id> 100 or employee_id <1000;
Order
Desc
Select * from employees where employee_id between 100 and 102 order by employee_id desc;
Asc
Select * from employees where employee_id between 100 and 102 order by employee_id asc;
The dual table can be used when no table needs to be queried.
Select sysdate from dual;
Select 1*2*3*4*5 from dual; bitsCN.com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service