mysql查询将三个查询连接成单个查询

时间:2013-09-19 11:14:15

标签: mysql join

请帮助解决此问题,这里是sql fiddler:http://sqlfiddle.com/#!2/8acc1/1

SELECT DISTINCT c.id, v.sel_category,c.curr_tittle , c.curr_desc, v.videos_desc 
FROM  wp_curriculum c, wp_career_vidoes v 
WHERE c.id IN 
   (SELECT DISTINCT curr_id 
    FROM wp_curriculum_category 
    WHERE curr_category IN (2,3)) AS I 

AND I.curr_category = v.sel_category 
GROUP BY I.curr_category

1 个答案:

答案 0 :(得分:3)

你是说这个吗?

SELECT  DISTINCT c.id, 
        v.sel_category,
        c.curr_tittle , 
        c.curr_desc, 
        v.videos_desc 
FROM    wp_curriculum c
        INNER JOIN wp_curriculum_category cat
            ON c.id = cat.curr_id
        INNER JOIN wp_career_vidoes v
            ON v.sel_category  = cat.curr_category
WHERE   cat.curr_category IN (2,3)

要进一步了解联接,请访问以下链接: