【问题标题】:List all the customers who are not active, with MySQL使用 MySQL 列出所有不活跃的客户
【发布时间】:2022-07-22 14:14:02
【问题描述】:

我有一些复杂的问题需要你的帮助:

问:列出所有不活跃的客户。

客户数据库:客户ID、姓名、地址.... 移动数据库:客户 ID、移动 ID、状态(空和取消日期)

如何编写 SQL 查询来根据状态检查哪些客户不活跃?

【问题讨论】:

    标签: python mysql join inner-join where-clause


    【解决方案1】:
    SELECT *
       FROM customerDB 
    JOIN mobileDB ON custumerDB.customerID = mobileDB.custumerID
    WHERE status IS NOT NULL
    

    【讨论】:

      【解决方案2】:
      SELECT *
      FROM Customer as c
      JOIN Mobile as m on m.customer_id = c.customer_id
      WHERE m.status is not Null
      

      您可以进一步扩展此查询以包含其他值:

      SELECT *
      FROM Customer as c
      JOIN Mobile as m on m.customer_id = c.customer_id
      WHERE 1=1
      and m.status is not Null
      and c.name = 'john'
      and c.mobileid in (293478, 2834783, 282383, 672723)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-12
        • 1970-01-01
        • 2014-02-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-28
        • 1970-01-01
        相关资源
        最近更新 更多