天天看點

select 1 from 表名

select 1 from table與select

* from table 從作用上來說是沒有差别的,都是檢視資料庫中這個表是否有記錄。select

1 from 中的1是一常量(可以為任意數值),查到的所有行的值都是它,但從效率上來說,1

>*,因為不用查字典表。

table表是一個資料表,假設表的行數為10行。

1:select 

1 from table       增加臨時列,每行的列值是寫在select後的數,這條sql語句中是1。當把1改為其他數,得出一個行數和table表行數一樣的臨時列,每行的列值是我寫在select後的數。

2:select

count(1)  from table   管count(a)的a值如何變化,得出的值總是table表的行數..

3:select

sum(a) from table   a代表任意數字,可以是小數、零、負數。得到的結果是:table表的行數×a