How to select rows where multiple joined table values meet selection criteria?

前端 未结 3 1520
我寻月下人不归
我寻月下人不归 2021-01-20 17:58

Given the following sample table schema

Customer Table

CustID
1
2
3

Invoice Table

CustID InvoiceID

1       10
1            


        
3条回答
  •  独厮守ぢ
    2021-01-20 18:39

    select CustID
        from InvoiceTable
        where InvoiceID in (10,20)
        group by CustID
        having COUNT(distinct InvoiceID) = 2
    

提交回复
热议问题