【问题标题】:How to get employee name and id who have two phone numbers in second table如何获取第二个表中有两个电话号码的员工姓名和身份证
【发布时间】:2017-02-07 10:07:22
【问题描述】:

这是两个表 1.emp_table,2.phone_table。 如何获取第二个表中有两个电话号码的员工姓名和身份证

【问题讨论】:

    标签: join common-table-expression derived-table


    【解决方案1】:
    SELECT t1.id,
           t1.name
    FROM emp_table t1
    INNER JOIN                   -- the join will remove employees who do not have
    (                            -- two phone numbers in phone_table
        SELECT Id
        FROM phone_table         -- this query identifies all employees
        GROUP BY Id              -- having two phone numbers in phone_table
        HAVING COUNT(*) = 2
    ) t2
        ON t1.id = t2.Id
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-13
      • 2021-03-16
      • 2013-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多