亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      考試首頁 | 考試用書 | 培訓課程 | 模擬考場 | 考試論壇  
      全國  |             |          |          |          |          |         
        當前位置:計算機等級 > 二級考試 > MySQL數(shù)據(jù)程序設(shè)計 > MySQL 輔導(dǎo) > 文章內(nèi)容
        

      全國計算機等級考試二級MySQL教程(52)

      中華IT學院   【 】  [ 2016年2月20日 ]

      我們在TUTORIALS數(shù)據(jù)庫中有兩張表 tcount_tbl 和 tutorials_tbl。兩張數(shù)據(jù)表數(shù)據(jù)如下:

      實例

      嘗試以下實例:

      root@host# mysql -u root -p password;
      Enter password:*******
      mysql> use TUTORIALS;
      Database changed
      mysql> SELECT * FROM tcount_tbl;
      +-----------------+----------------+
      | tutorial_author | tutorial_count |
      +-----------------+----------------+
      | mahran          |             20 |
      | mahnaz          |           NULL |
      | Jen             |           NULL |
      | Gill            |             20 |
      | John Poul       |              1 |
      | Sanjay          |              1 |
      +-----------------+----------------+
      6 rows in set (0.01 sec)
      mysql> SELECT * from tutorials_tbl;
      +-------------+----------------+-----------------+-----------------+
      | tutorial_id | tutorial_title | tutorial_author | submission_date |
      +-------------+----------------+-----------------+-----------------+
      |           1 | Learn PHP      | John Poul       | 2007-05-24      |
      |           2 | Learn MySQL    | Abdul S         | 2007-05-24      |
      |           3 | JAVA Tutorial  | Sanjay          | 2007-05-06      |
      +-------------+----------------+-----------------+-----------------+
      3 rows in set (0.00 sec)
      mysql>
      

      接下來我們就使用MySQL的JOIN來連接以上兩張表來讀取tutorials_tbl表中所有tutorial_author字段在tcount_tbl表對應(yīng)的tutorial_count字段值:

      mysql> SELECT a.tutorial_id, a.tutorial_author, b.tutorial_count
          -> FROM tutorials_tbl a, tcount_tbl b
          -> WHERE a.tutorial_author = b.tutorial_author;
      +-------------+-----------------+----------------+
      | tutorial_id | tutorial_author | tutorial_count |
      +-------------+-----------------+----------------+
      |           1 | John Poul       |              1 |
      |           3 | Sanjay          |              1 |
      +-------------+-----------------+----------------+
      2 rows in set (0.01 sec)
      mysql>
      分享到:
      本文糾錯】【告訴好友】【打印此文】【返回頂部
      將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動訪問考試網(wǎng) | 復(fù)制本頁地址,傳給QQ/MSN上的好友 | 申請鏈接 | 意見留言 TOP
      關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
      Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved