PHP學(xué)習(xí)之SQL語(yǔ)句快速入門(mén)
更新時(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啞元表沒(méi)有表需要查詢(xún)的時(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啞元表沒(méi)有表需要查詢(xún)的時(shí)候可以用它
select sysdate from dual;
select 1*2*3*4*5 from dual;
您可能感興趣的文章:
- PHP格式化MYSQL返回float類(lèi)型的方法
- PHP+Mysql日期時(shí)間如何轉(zhuǎn)換(UNIX時(shí)間戳和格式化日期)
- php執(zhí)行sql語(yǔ)句的寫(xiě)法
- 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學(xué)習(xí)之?dāng)?shù)據(jù)庫(kù)表五大約束詳解小白篇
本篇文章非常適合MySQl初學(xué)者,主要講解了MySQL數(shù)據(jù)庫(kù)的五大約束及約束概念和分類(lèi),有需要的朋友可以借鑒參考下,希望可以有所幫助2021-09-09
MySQL事務(wù)的隔離性是如何實(shí)現(xiàn)的
最近做了一些分布式事務(wù)的項(xiàng)目,對(duì)事務(wù)的隔離性有了更深的認(rèn)識(shí),后續(xù)寫(xiě)文章聊分布式事務(wù)。今天就復(fù)盤(pán)一下單機(jī)事務(wù)的隔離性是如何實(shí)現(xiàn)的?感興趣的可以了解一下-2021-09-09
mysql zip archive 版本(5.7.19)安裝教程詳細(xì)介紹
這篇文章主要介紹了mysql zip archive 版本(5.7.19)安裝教程詳細(xì)介紹,需要的朋友可以參考下2017-10-10
MySQL時(shí)區(qū)查看及設(shè)置全過(guò)程
在服務(wù)器環(huán)境下,MySQL默認(rèn)時(shí)區(qū)可能是UTC,需注意應(yīng)用時(shí)區(qū)設(shè)置,若查詢(xún)條件使用Now()/sysdate(),會(huì)根據(jù)MySQL時(shí)區(qū)查詢(xún),導(dǎo)致時(shí)間錯(cuò)亂,可使用`selectnow()`檢查時(shí)間準(zhǔn)確性,查看和修改MySQL時(shí)區(qū)的方法包括使用命令和修改配置文件2025-01-01
MySQL最大連接數(shù)max_connections設(shè)置的兩種方法
MySQL的最大連接數(shù)可以通過(guò)兩種方法進(jìn)行設(shè)置,通過(guò)命令行臨時(shí)修改和通過(guò)配置文件永久修改這兩種方法,本文將通過(guò)代碼示例給大家詳細(xì)的講解一下這兩種方法,需要的朋友可以參考下2024-05-05
MYSQL的存儲(chǔ)過(guò)程和函數(shù)簡(jiǎn)單寫(xiě)法
簡(jiǎn)單的說(shuō),就是一組SQL語(yǔ)句集,功能強(qiáng)大,可以實(shí)現(xiàn)一些比較復(fù)雜的邏輯功能,類(lèi)似于JAVA語(yǔ)言中的方法,這里就為大家簡(jiǎn)單介紹一下,需要的朋友可以參考下2018-05-05

