不同的mysql查询结合起来

时间:2012-06-27 07:20:56

标签: mysql

select m.*, c.NAME as CORP_NAME 
from MAIL_LOG as m, CORP as c 
where m.SEND_DATE >= '$term_from' and m.SEND_DATE <= '$term_end' ";

Select DISTINCT `TO_NAME_F_KANA` from MAIL_LOG group by m.SEND_DATE;

我希望从TO_NAME_F_KANA作为参考的第一个查询中获取唯一值。

1 个答案:

答案 0 :(得分:1)

以下查询应该可以解决问题

Select DISTINCT t.`TO_NAME_F_KANA` from 
     (
     select m.*, c.NAME as CORP_NAME 
     from MAIL_LOG as m, CORP as c 
      where 
           m.SEND_DATE >= '$term_from'
                  and
           m.SEND_DATE <= '$term_end'
     ) t
group by t.SEND_DATE;