首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否过滤SQL结果?

是否过滤SQL结果?
EN

Stack Overflow用户
提问于 2014-03-06 16:51:33
回答 2查看 76关注 0票数 2

我在状态3和状态1中收到了相同的电子邮件。我只需要显示状态3的电子邮件,这个查询是在状态3的页面中显示我,也是状态1的电子邮件

下面是我的问题:

代码语言:javascript
运行
复制
 SELECT live_customers.Id, live_customers.date,
        live_customers.firstname, live_customers.lastname, live_customers.phone,
        live_customers.phone2, live_customers.email, live_customers.num_sellers, 
        live_customers.sell_date,live_customers.public_description,  
        live_customers.public_image, live_customers.price,
        live_customers.takanon, live_customers.confirm_mail_sent, live_customers.paid,
        live_customers.shirt_size, live_customers.shirt_size_extra, 
        live_customers.stand_rent, live_customers.refunded, live_customers.call1,
        live_customers.call2, live_customers.notes,
        live_customers.auth_number, live_customers.hasContact, live_customers.IP, 
        live_customers.status, live_status.name AS StatusName, 
        live_status.color AS StatusColor, live_compound.name AS CompoundName 
   FROM live_customers
        INNER JOIN live_status 
                   ON live_status.Id=live_customers.status          
        INNER JOIN
        LEFT JOIN live_compound 
                   ON live_compound.Id=live_customers.compound_id
   WHERE live_customers.status='3'                         
   GROUP BY 
        live_customers.Id 
   ORDER BY 
        live_customers.Id DESC 
   LIMIT 0,30
EN

回答 2

Stack Overflow用户

发布于 2014-03-06 16:59:19

您已经混合了内连接和左连接...

尝尝这个

代码语言:javascript
运行
复制
SELECT live_customers.Id, live_customers.date,
        live_customers.firstname, live_customers.lastname, live_customers.phone,
        live_customers.phone2, live_customers.email, live_customers.num_sellers, 
        live_customers.sell_date,live_customers.public_description,  
        live_customers.public_image, live_customers.price,
        live_customers.takanon, live_customers.confirm_mail_sent, live_customers.paid,
        live_customers.shirt_size, live_customers.shirt_size_extra, 
        live_customers.stand_rent, live_customers.refunded, live_customers.call1,
        live_customers.call2, live_customers.notes,
        live_customers.auth_number, live_customers.hasContact, live_customers.IP, 
        live_customers.status, live_status.name AS StatusName, 
        live_status.color AS StatusColor, live_compound.name AS CompoundName 
   FROM live_customers
        INNER JOIN live_status 
                   ON live_status.Id=live_customers.status          
        INNER JOIN live_compound 
                   ON live_compound.Id=live_customers.compound_id
   WHERE live_customers.status='3'                         
   GROUP BY 
        live_customers.Id 
   ORDER BY 
        live_customers.Id DESC 
   LIMIT 0,30
票数 0
EN

Stack Overflow用户

发布于 2014-03-06 19:12:46

我找到了我问题的解决方案。这就是了。希望这能对某些人有所帮助

代码语言:javascript
运行
复制
   SELECT  live_customers.Id, live_customers.date,
           live_customers.firstname, live_customers.lastname, live_customers.phone,
           live_customers.phone2, live_customers.email, live_customers.num_sellers, 
           live_customers.sell_date,live_customers.public_description,  
           live_customers.public_image, live_customers.price,
           live_customers.takanon, live_customers.confirm_mail_sent, live_customers.paid,
           live_customers.shirt_size, live_customers.shirt_size_extra, 
           live_customers.stand_rent, live_customers.refunded, live_customers.call1,
           live_customers.call2, live_customers.notes,
           live_customers.auth_number, live_customers.hasContact, live_customers.IP, 
           live_customers.status, live_status.name AS StatusName, 
           live_status.color AS StatusColor, live_compound.name AS CompoundName 
   FROM live_customers
        INNER JOIN live_status 
               ON live_status.Id=live_customers.status          
        INNER JOIN live_compound 
               ON live_compound.Id=live_customers.compound_id                   

        WHERE live_customers.status='3'  
        AND live_customers.Email NOT IN (SELECT Email FROM live_customers WHERE status=1)                  
        GROUP BY 
    live_customers.Id 
        ORDER BY 
    live_customers.Id DESC 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22219390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档