<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Skynet

    ---------- ---------- 我的新 blog : liukaiyi.cublog.cn ---------- ----------

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      112 Posts :: 1 Stories :: 49 Comments :: 0 Trackbacks

    在線文檔參考

    jdbc url: 詳細屬性可參考

    Eg: jdbc:mysql://localhost:3306/test?user =root&password=&useUnicode=true&characterEncoding=utf8

    mysql URL: mysql -uroot -p --default-character-set=utf8


    協調 SQL 詳細:

      這就重點說下:SHOW

      1. 查看全部庫支持字符 如:'gb%'  -gbk,gb2312

          SHOW CHARACTER SET LIKE '%' ;

      2. 查看列

      show columns from user from mysql ;
      show columns from mysql.user ;
      desc mysql.user ;
      //簡化
      //更方便的 查看 列名 模糊查詢列名為 'Select%' (desc  information_schema.columns 還有更多驚喜)

      select column_name from information_schema.columns where column_name like 'Select%' ;

      3. 查看數據庫,表結構;當然你們也可以仿照下此再建自己的庫,表

       show
       show create database information_schema"G
       show create table mysql.user"G

      4.權限查看

       SHOW GRANTS FOR 'root'@'localhost';

      .....(詳細參考


    SQL 詳細

    這就上寫自己一些有感覺的sql :參考

    1.只查詢重復 Eg:

    create   table  c (id  int  );
    insert   into  c  values  ( 1 ),( 2 ),( 3 ),( 4 ),( 3 ),( 5 ),( 6 ),( 1 );
    結果:
        
    select  id  from  c  group   by  id  having   count (id) > 1  ;

    2.報表查詢橫向輸出 Eg:

    Create table d(id int,name varchar(50));
    insert into d values(1,'gly');
    insert into d values(2,'ptgly');
    insert into d values(3,'ybgly');
    insert into d values(4,'ptgly');
    insert into d values(5,'ybgly');
    +---+-----+------+
    |gly |ptgly|ybgly|     
    +---+-----+------+-
     |1   |2     |2      |
    +---+-----+------+

    select  
        
    sum ( case   when  name = ' gly '   then   1   else   0   end  )  as  gly  ,
        
    sum ( case   when  name = ' ptgly '   then   1   else   0   end  )  as  ptgly  ,
        
    sum ( case   when  name = ' ybgly '   then   1   else   0   end  )  as  ybgly  
    from  d ;

    3.復雜組合查詢

    create table table_a (No int, No2 int,num double,itime date);
    insert into table_a values
         (1234,567890,33.5,'2004-12-21'),
         (1234,598701,44.8,'2004-11-21'),
         (1234,598701,45.2,'2004-10-01'),
         (1234,567890,66.5,'2004-9-21'),
         (3456,789065,22.5,'2004-10-01'),
         (3456,789065,77.5,'2004-10-27'),
         (3456,678901,48.5,'2004-12-21');
    按月統計銷售表中貨物的銷售量數
    查詢結果如下:
      No, No2 ,   九月,  十月,十一月,十二月
    1234,567890, 66.5 ,  0 ,  0  ,  33.5
    1234,598701,  0   , 45.2, 44.8, 0
    3456,789065, 0  ,  100,  0  ,  0
    3456,678901, 0 ,    0,    0  ,  48.5
    -----------------------------------------------------------------------

    //當然也可以 使用mysql 時間函數 在軟件編輯時 你可以輸入 String[] 并根據數據動態拼寫 sql( case部分!! )
    //這個 例子很好 哦!報表可以一句sql 得出!

    select  NO,NO2,
        
    sum ( case    when  itime  like   ' 2004-%9% '   then  num  else   0   end as  9M,
        
    sum ( case    when  itime  like   ' 2004-10% '   then  num  else   0   end as  10M,
        
    sum ( case    when  itime  like   ' 2004-11% '   then  num  else   0   end as  11M,
        
    sum ( case    when  itime  like   ' 2004-12% '   then  num  else   0   end as  12M
    from  table_a  group   by  no,no2  order   by  no,no2 ;


    4.字符集子層關系
    1     a
    2     b
    11    c
    (代碼11表示為1的下級)
    我要通過一條句子,得出如下結果:
    Create table TabTest(t_Code varchar(10),t_Name varchar(10));
    insert into TabTest values('1','a');
    insert into TabTest values('2','b');
    insert into TabTest values('11','c');
    --------------------------------------------------------------

    select  tt1.t_Code,tt1.t_name,( 
         
    case  
                 
    when   exists  ( select   1   from  tabtest tt2 
                                           
    where  tt2.t_code  like  CONCAT(tt1.t_code, ' % ' and  
                                            tt2.t_code 
    <>  tt1.t_code )   then   ' you '  
                 
    else   ' wu '
          
    end  )  as  you_wu
    from  tabtest  tt1 ;


    整理 m.tkk7.com/Good-Game
    posted on 2008-10-01 17:22 劉凱毅 閱讀(2344) 評論(0)  編輯  收藏 所屬分類: database
    主站蜘蛛池模板: 久久精品国产亚洲7777| 国产高清免费在线| 国产成人亚洲综合无码精品| 日韩成人毛片高清视频免费看| 在线免费一区二区| 亚洲人成网国产最新在线| 在线观看免费人成视频色9| 日韩精品无码免费专区网站| 亚洲精品无码专区2| 一本岛v免费不卡一二三区| 久久精品亚洲福利| 国产亚洲精品免费视频播放 | 久久影视综合亚洲| 亚洲免费观看视频| 毛片免费视频观看| 亚洲精品无码你懂的| 国产jizzjizz免费看jizz| 一级毛片免费不卡| 国产亚洲av片在线观看播放| 青青青国产手机频在线免费观看 | 国产成人亚洲综合a∨| 精品亚洲一区二区三区在线播放| 国产福利免费视频| 久久久亚洲精品视频| 免费H网站在线观看的| 国产成人精品久久亚洲高清不卡| 亚洲国产天堂久久久久久| 一个人免费视频在线观看www| 亚洲精品高清国产麻豆专区| 成人a免费α片在线视频网站| 免费一级特黄特色大片| 亚洲精品线在线观看| 成人性生交大片免费看午夜a| 黄色a三级免费看| 亚洲国产国产综合一区首页| 成年人免费网站在线观看| 免费播放国产性色生活片| 亚洲人成在线观看| 国产无遮挡又黄又爽免费视频 | 免费视频淫片aa毛片| 成年免费a级毛片免费看无码|