學習了一點sql語句

2021-09-20 05:35:44 字數 1928 閱讀 3779

1.sql大小寫不敏感,

2.select name,name from 表//從資料庫中查整張表,

3.select * from 表

4.只輸出名字和國家 select name,country from 表

5.在表中,乙個列可能會包含多個重複值,有時您也許希望僅僅列出不同(distinct)的值。select distinct name,name from 表 ,輸出名字不同的表

select distinct name from 表//從資料庫中只查名字

6.where 子句用於提取那些滿足指定標準的記錄。select * from 表 where name='安';

7.如果第乙個條件和第二個條件都成立,則 and 運算子顯示一條記錄。

如果第乙個條件和第二個條件中只要有乙個成立,則 or 運算子顯示一條記錄。and & or 運算子用於基於乙個以上的條件對記錄進行過濾。and 和 or  select * from 表 where country='usa' and id>5;都滿足的 。select * from 表 where country='usa' or id>5滿足其一

二者結合 select * from 表 where id>5 and (country='usa' or country='中國');

8.order by 關鍵字用於對結果集按照乙個列或者多個列進行排序。

order by 關鍵字預設按照公升序對記錄進行排序。如果需要按照降序對記錄進行排序,您可以使用 desc 關鍵字。

select * from 表 order by country,id; select * from 表 order by country (desc); 

9.update 語句用於更新表中已存在的記錄。update 表 set country='usa',alexa=500 where name='菜鳥教程';

10.delete 語句用於刪除表中的行。delete from 表 where country='usa' and alexa=500;

11.select top 子句用於規定要返回的記錄的數目。select * from 表 limit 5;

12.like 操作符用於在 where 子句中搜尋列中的指定模式。select * from 表 where name like 'g%';  select * from 表 where name like '%oo%';帶

13.在 sql 中,萬用字元與 sql like 操作符一起使用。

sql 萬用字元用於搜尋表中的資料。

在 sql 中,可使用以下萬用字元:select * from 表 where name regexp '[^gfs]'下面的 sql 語句選取 name 以 "g"、"f" 或 "s" 開始的所有**;select * from 表 where name regexp '^[a-h]'('^[^a-h]')下面的 sql 語句選取 name 以 a 到 h 字母開頭的**:(下面的 sql 語句選取 name 不以 a 到 h 字母開頭的**:)

14.in 操作符允許您在 where 子句中規定多個值。select * from 表 where name in ('中國','usa');

15.between 操作符選取介於兩個值之間的資料範圍內的值。這些值可以是數值、文字或者日期。select * from 表 where alexa (not)between 1 and 20;在或不在

下面的 sql 語句選取alexa介於 1 和 20 之間但 country 不為 usa 和 ind 的所有**:select * from 表 where( alexa between 1 and 20 )and not country in('中國','usa');

下面的 sql 語句選取 name 以介於(不介於) 'a' 和 'h' 之間字母開始的所有**:select * from 表 where name (not) between 'a' and 'h';

今天學習了一點viewstate

今天看了一篇文章,為 http weblogs.asp.net infinitiesloop archive 2006 08 03 truly understanding viewstate.aspx 裡面詳細講解了viewstate,沒有完全看明白 汗ing.但也了解了一些知識.viewstate...

關於SQL語句Count的一點細節

count語句支援 列名 常量 變數,並且可以用distinct關鍵字修飾,並且count 列名 不會累計null的記錄。下面隨便用一些例子示範一下count的規則 比如對如下表做統計,所有列這裡都用sql variant型別來表示。if object id t test 0 drop table ...

關於SQL語句Count的一點細節

count語句支援 列名 常量 變數,並且可以用distinct關鍵字修飾,並且count 列名 不會累計null的記錄。下面隨便用一些例子示範一下count的規則 比如對如下表做統計,所有列這裡都用sql variant型別來表示。if object id t test 0 drop table ...