1. 程式人生 > >資料庫基礎操作

資料庫基礎操作

  1. 顯示查詢結果使用排序功能
    order by [列名] desc; #desc 表示降序,asc 表示升序
    例:select * from 表名 where ID = '001' order by createtime desc;
    createtime(建立時間) ,預設顯示時間為升序,使用order by [列名] desc 轉為降序顯示

  2. 把多條查詢語句結果顯示在一個視窗:union all
    ---例:把下面3條結果顯示在同一視窗------
    select from 表名 where ID = '001' union all
    select
    from 表名 where ID = '002' union all
    select * from 表名 where ID = '003'