Mar 02, 2006
MySQLのデータベースからデータを抽出する
PHPなどとMySQLの連携だと、MySQLの文法の学習も必要になる。 
またにわか勉強(^^)。 
下の記事で作ったデータベースとテーブルから、投稿記事の多い順に書き手の方々を抽出する。それも100件以上書かれた方(自分含む^^)を。 
書き手でグループ化して、その書き手の書いた数を「as」で名前をつけて、それで並べる。 
mysql> select count(bbs_auth) as cnt,bbs_auth from gs_book group by bbs_auth having count(bbs_auth)>=100 order by cnt desc; 
+------+------------------+ 
| cnt  | bbs_auth         | 
+------+------------------+ 
| 1449 | 清水鱗造         | 
| 1078 | 冨澤守治         | 
|  525 | 桐田真輔         | 
|  448 | mitsui K&T       | 
|  414 | A・T           | 
|  285 | TISATO     | 
|  238 | 河合民子         | 
|  210 | 木村             | 
|  196 | 関ofuji          | 
|  164 | tomizawa         | 
|  122 | ぺこ (¨*)(*¨)  | 
|  121 | (*''*)peco!     | 
|  106 | (*''*)peco!    | 
+------+------------------+ 
13 rows in set (0.10 sec) 
wikieditish message: Ready to edit this entry.
A quick preview will be rendered here when you click "Preview" button.