PHP學(xué)習(xí)之SQL語(yǔ)句快速入門
更新時(shí)間:2010年03月23日 22:46:57 作者:
在學(xué)校php過(guò)程中,需要用得到的一些語(yǔ)句。比較簡(jiǎn)單的大家一定要掌握啊。
Select * 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;
||連接符使用以及 加減乘除以及括號(hào)的使用
SQL> select employee_id,first_name||'.'||last_name,salary*(1+0.1)/100,manager_id
2 from employees;
+-做正負(fù)號(hào)使用
SQL> select -salary from employees;
<>,>,<,=,!=等比較操作符
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(比任意一個(gè)都)
select * from employees where employee_id >any(100,101,102);
some 是 SQL-92 標(biāo)準(zhǔn)的 any 的等效物
select * from employees where employee_id >any(100,101,102);
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;
邏輯操作符
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 by
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;
dual啞元表沒有表需要查詢的時(shí)候可以用它
select sysdate from dual;
select 1*2*3*4*5 from dual;
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;
||連接符使用以及 加減乘除以及括號(hào)的使用
SQL> select employee_id,first_name||'.'||last_name,salary*(1+0.1)/100,manager_id
2 from employees;
+-做正負(fù)號(hào)使用
SQL> select -salary from employees;
<>,>,<,=,!=等比較操作符
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(比任意一個(gè)都)
select * from employees where employee_id >any(100,101,102);
some 是 SQL-92 標(biāo)準(zhǔn)的 any 的等效物
select * from employees where employee_id >any(100,101,102);
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;
邏輯操作符
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 by
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;
dual啞元表沒有表需要查詢的時(shí)候可以用它
select sysdate from dual;
select 1*2*3*4*5 from dual;
您可能感興趣的文章:
- PHP格式化MYSQL返回float類型的方法
- PHP+Mysql日期時(shí)間如何轉(zhuǎn)換(UNIX時(shí)間戳和格式化日期)
- php執(zhí)行sql語(yǔ)句的寫法
- PHP+MySQL 手工注入語(yǔ)句大全 推薦
- PHP執(zhí)行批量mysql語(yǔ)句的解決方法
- PHP 批量刪除 sql語(yǔ)句
- PHP mysqli 增強(qiáng) 批量執(zhí)行sql 語(yǔ)句的實(shí)現(xiàn)代碼
- php mssql 分頁(yè)SQL語(yǔ)句優(yōu)化 持續(xù)影響
- PHP+Mysql實(shí)現(xiàn)多關(guān)鍵字與多字段生成SQL語(yǔ)句的函數(shù)
- php mssql 數(shù)據(jù)庫(kù)分頁(yè)SQL語(yǔ)句
- PHP之Mysql常用SQL語(yǔ)句示例的深入分析
- PHP實(shí)現(xiàn)SQL語(yǔ)句格式化功能的方法
相關(guān)文章
MySQL for update鎖表還是鎖行校驗(yàn)(過(guò)程詳解)
在MySQL中,使用for update子句可以對(duì)查詢結(jié)果集進(jìn)行行級(jí)鎖定,以便在事務(wù)中對(duì)這些行進(jìn)行更新或者防止其他事務(wù)對(duì)這些行進(jìn)行修改,這篇文章主要介紹了MySQL for update鎖表還是鎖行校驗(yàn),需要的朋友可以參考下2024-02-02MySQL遞歸查詢的3種實(shí)現(xiàn)方式實(shí)例
在項(xiàng)目中會(huì)遇到同一個(gè)表中保存著父子關(guān)系的數(shù)據(jù),最常見的就是處理樹形結(jié)構(gòu)資源,下面這篇文章主要給大家介紹了關(guān)于MySQL遞歸查詢的3種實(shí)現(xiàn)方式,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-04-04MySQL如何快速批量插入1000w條數(shù)據(jù)
這篇文章主要給大家介紹了關(guān)于MySQL如何快速批量插入1000w條數(shù)據(jù)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03配置hive元數(shù)據(jù)到Mysql中的全過(guò)程記錄
這篇文章主要給的大家介紹了關(guān)于配置hive元數(shù)據(jù)到Mysql中的全過(guò)程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10MySQL中DATE_FORMATE函數(shù)使用時(shí)的注意點(diǎn)
這篇文章主要介紹了MySQL中DATE_FORMATE函數(shù)使用時(shí)的注意點(diǎn),主要是針對(duì)其內(nèi)置的字符集使用時(shí)需要轉(zhuǎn)換而進(jìn)行說(shuō)明,需要的朋友可以參考下2015-05-05