經典sql查詢語句

2021-10-11 03:19:54 字數 1296 閱讀 3800

以下如果是數字型別的鍵值,就不應該加單引號。

【=】等於

select * from persons where city=『beijing』

select * from 要查詢的表名 where 鍵名=『鍵值』

【<>】不等於

select * from persons where city<>『beijing』

select * from 要查詢的表名 where 鍵名<>『鍵值』

【>】大於

select * from persons where citycode>110000

select * from 要查詢的表名 where 鍵名》鍵值

【between…and…】按範圍查詢

select * from iphone6 where score between 85 and 90

select * from 要查詢的表名 where 鍵名 between 鍵值的最小取值範圍 and 鍵值的最大取值範圍

【like…開頭%】以開頭查詢

select * from sysdetectitem where reaction like 『採%』

select * from 要查詢的表名 where 鍵名 like 『鍵值的開頭%』

【like…%結尾】以結尾查詢

select * from sysdetectitem where reaction like 『%法』

select * from 要查詢的表名 where 鍵名 like 『%鍵值的結尾』

【like…%鍵值的關健詞%】以關健詞查詢

select * from sysdetectitem where reaction like 『%法%』

select * from 要查詢的表名 where 鍵名 like 『%鍵值的關健詞%』

【order by … asc】公升序排列

select * from iphone6 order by score asc

select * from 要查詢的表名 order by 鍵名 asc

【order by … desc】降序排列

select * from iphone6 order by score desc

select * from 要查詢的表名 order by 鍵名 desc

【in】多鍵值查詢

select * from sysdetectitem where unit in (『mmol/l』,『μmol/l』)

select * from 要查詢的表名 where 鍵名 in (『鍵值1』,『鍵值2』)

sql經典語句

說明 複製表 只複製結構,源表名 a 新錶名 b access可用 方法一 select into b from a where 1 1 方法二 select top 0 into b from a 注意 複製的新錶中的所有欄位都將沒有預設值,即使源表中有設預設值 說明 一條sql 語句搞定資料庫分...

經典sql語句

經典sql語句大全 update 有關update,急!在oracle資料庫中 表 a id firstname,lastname 表 b id,lastname 表 a 中原來id,firstname兩個欄位的資料是完整的 表 b中原來id,lastname兩個欄位的資料是完整的 現在要把表 b中...

經典SQL語句

假設只有乙個table,名為pages,有四個字段,id,url,title,body。裡面儲存了很多網頁,網頁的url位址,title和網頁的內容,然後你用乙個sql查詢將url匹配的排在最前,title匹配的其次,body匹配最後,沒有任何字段匹配的,不返回。如下 用union 實現聯合查詢,在...