多个不同于多个表

时间:2014-04-23 12:22:24

标签: mysql

MySQL请求是:

SELECT  DISTINCT a.field_department_color_value, DISTINCT a.nid,  DISTINCT c.nid, DISTINCT c.field_oeuvre_notice_bibliography_value, DISTINCT c.field_oeuvre_notice_author_value, DISTINCT d.field_oeuvre_cartel_dimension_value, DISTINCT d.field_oeuvre_cartel_origin_value

FROM (                
                SELECT DISTINCT field_department_color_value,nid
                                FROM content_type_department) a,

                (       SELECT field_oeuvre_notice_dep_value
                            FROM content_field_oeuvre_notice_dep) b,

                (       SELECT field_oeuvre_notice_bibliography_value, field_oeuvre_notice_author_value, field_oeuvre_notice_cartel_nid
                            FROM content_type_oeuvre_notice) c,

                 (      SELECT field_oeuvre_cartel_dimension_value, field_oeuvre_cartel_origin_value, nid
                            FROM content_type_oeuvre_cartel) d,



WHERE    a.nid = b.field_oeuvre_notice_dep_value
AND      d.nid = c.field_oeuvre_notice_cartel_nid
AND      a.field_department_color_value LIKE 'greek'
LIMIT 0 , 8

它仅对属性field_department_color_value有所区别!虽然我想为SELECT部分​​中的所有属性执行此操作...谢谢

1 个答案:

答案 0 :(得分:0)

尝试

SELECT DISTINCT a.field_department_color_value, 
a.nid,  
c.nid, 
c.field_oeuvre_notice_bibliography_value, 
c.field_oeuvre_notice_author_value, 
d.field_oeuvre_cartel_dimension_value, 
d.field_oeuvre_cartel_origin_value

FROM (                
                SELECT DISTINCT field_department_color_value,nid
                                FROM content_type_department) a,

                (       SELECT field_oeuvre_notice_dep_value
                            FROM content_field_oeuvre_notice_dep) b,

                (       SELECT field_oeuvre_notice_bibliography_value, field_oeuvre_notice_author_value, field_oeuvre_notice_cartel_nid
                            FROM content_type_oeuvre_notice) c,

                 (      SELECT field_oeuvre_cartel_dimension_value, field_oeuvre_cartel_origin_value, nid
                            FROM content_type_oeuvre_cartel) d,



WHERE    a.nid = b.field_oeuvre_notice_dep_value
AND      d.nid = c.field_oeuvre_notice_cartel_nid
AND      a.field_department_color_value LIKE 'greek'
LIMIT 0 , 8