SQLite - where clause not work with two columns

时间:2018-12-03 12:48:42

标签: sql sqlite

In sqlite I has query:

select * FROM notification_invoice where (notificationDate, ownerKey) IN (
  select distinct notificationDate, ownerKey FROM notification_invoice where providerId in ("12345","6789") 
)

But I get error:

Error: [SQLITE_ERROR] SQL error or missing database (near ",": syntax error)
SQLState:  null
ErrorCode: 1

1 个答案:

答案 0 :(得分:2)

I don't think SQLite supports tuples with in. Just use exists:

select ni.* 
from notification_invoice ni
where exists (select 1
              from notification_invoice ni2
              where ni2.notificationDate = ni.notificationDate and
                    ni2.ownerKey and ni.ownerKey and
                    ni2.providerId in ('12345', '6789') 
             );