java基礎(九章)

來源:互聯網
上載者:User

標籤:desc   select   sel   order by   tor   發送   後台服務   機制   伺服器   

一、理解查詢的機制

       用戶端應用程式(c/s、b/s)向後台伺服器的DB發送一條select語句進行查詢操作,會將結果集(虛擬表)返回到用戶端應用程式

二、select語句

1、查詢表中的全部列和行

       select * from 表名

2、根據條件查詢資料

       select * from 表名 where 條件

3、查詢部分列的資料

              select 列名1,列名2…. from 表名 [where條件]

4、為列名取別名

              方式1:select 列名 as 別名 from 表名[where條件]

              方式2:select 列名 別名 from 表名[where條件]

              方式3:select別名=列名from 表名[where條件]

5、常量列

              select ‘常量值’ as 常量列名 from 表名[where條件]

6、提取表中的行數

              方式1:提取固定的行

                     select  top 行數 列名 from 表名 [where條件]

              方式2:按百分比提取資料行

                select  top 百分比 percent 列名 from 表名 [where條件]

7、查詢資料,並排序

              升序:

select 列名列表 from 表名  [where條件]torder by 排序的列名 【asc】

              降序:

select 列名列表 from 表名  [where條件]

order by 排序的列名 desc

8、查詢表中某列為空白值的資料行

select 列名列表 from 表名 where 列名=’’ or 列名 is null

java基礎(九章)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.