? 在一中介紹了簡單的查詢語句留晚。在這里說一下其他的查詢語句。
1扒最、select? distinct 列名 from s表名;
?????????? DISTINCT關(guān)鍵字:指示數(shù)據(jù)庫只返回不同的值
2丑勤、between...and...語句
????? between ...and..語句返回指定數(shù)據(jù)范圍內(nèi)的數(shù)據(jù)。
??? 例如:select * from 表名 where id between 1 and 10;
???? 返回id為1到10 的行吧趣。
????? 當(dāng)然也可以在between前面家not? 以顯示不在次范圍內(nèi)的數(shù)據(jù)法竞。
3、in 關(guān)鍵字
????? select * from 表名 where 列名 in(元素1强挫,元素2...);
????? 查找屬于in后面元素的數(shù)據(jù)岔霸,當(dāng)然也可以在in前面加not
4、like關(guān)鍵字
? ?????? 使用 LIKE 運(yùn)算選擇類似的值
? ? ????? 選擇條件可以包含字符或數(shù)字:
??????????? % 代表零個(gè)或多個(gè)字符(任意個(gè)字符)俯渤。
???????????? _ 代表一個(gè)字符呆细。
???????? select 列名1,列名2... from 表名 where 列名 like ..;
? ? ? 例如:select name from student where name like ‘張%’;? 則姓為張的都會(huì)被顯示出來八匠。
5侦鹏、AVG函數(shù)
? ? ? AVG函數(shù)返回滿足where條件的一列的平均值
? ? Select AVG( 列名 ) { ,AVG( 列名 )... } from tablename? where ...;
6.count函數(shù)
? ? Count(列名)返回某一列,行的總數(shù)。
? ? select??? count( 列名 ) from tablename where...;
7.max/min
? ?? select?? max/min( 列名 ) from tablename where...;
8.sum
??? ?? Sum函數(shù)返回滿足where條件的行的和
????? select sum( 列名 ) from tablename where...;
9.Order by 排序功能
SELECT column1, column2. column3..FROM? table order by column asc|desc;