日期:2014-05-16 浏览次数:22047 次
mysql> select * from forum; +-----+----------+ | fid | name | +-----+----------+ | 1 | Discuz! | | 2 | 默认版块 | | 3 | 影音 | | 4 | 情感 | | 5 | 生活 | | 6 | 休闲 | | 7 | 游戏 | | 8 | 体育 | | 9 | 电影 | | 10 | 音乐 | | 11 | 视频 | | 12 | 电视 | | 13 | 交友 | | 14 | 单身 | | 15 | 诉说 | | 16 | 婚恋 | | 17 | 美食 | | 18 | 购物 | | 19 | 美容 | | 20 | 健康 | | 21 | 汽车 | | 22 | 时尚 | | 23 | 星座 | | 24 | 摄影 | | 25 | 宠物 | | 26 | 动漫 | | 27 | 旅游 | | 28 | 设计 | | 29 | 足球 | | 30 | 篮球 | | 31 | 羽毛球 | | 32 | 乒乓球 | | 33 | 网游 | | 35 | 单机 | | 36 | 动漫区 | | 37 | 漫画区 | | 38 | 动漫一 | | 39 | 动漫二 | | 40 | 动漫三 | +-----+----------+ 39 rows in set (0.00 sec) mysql> mysql> select * from label; +----+--------+ | ID | Name | +----+--------+ | 1 | 新番 | | 2 | 星期一 | +----+--------+ 2 rows in set (0.00 sec) mysql> mysql> select * from related; +----+---------+---------+ | ID | labelID | forumID | +----+---------+---------+ | 1 | 1 | 38 | | 2 | 2 | 38 | | 3 | 1 | 39 | +----+---------+---------+ 3 rows in set (0.00 sec) mysql> select f.fid, f.name -> from forum f inner JOIN related r1 ON r1.forumID = f.fid -> inner join related r2 on r2.forumID = f.fid -> inner JOIN label l1 ON r1.labelID = l1.ID -> inner JOIN label l2 ON r2.labelID = l2.ID -> where l1.Name = '新番' and l2.Name = '星期一'; +-----+--------+ | fid | name | +-----+--------+ | 38 | 动漫一 | +-----+--------+ 1 row in set (0.08 sec) mysql>