sql - select from table where both id exist -


i need select single table both id exists in column having matching id in column. query below gives rows single matching id.

select * customer_appdata appdata_id in(11,12)   id  customer_id appdata_id   6    65             4 7    65             12   8    65             8    9    66             11   10   66             12 

so here want last , second last rows(9,10) have both 11 , 12 common id 66.

this query selects rows customer_appdata of 12 or 11 , uses exists see if other row in table.

select * customer_appdata c1 appdata_id in (11,12) , exists (     select 1 customer_appdata c2     c2.appdata_id in (11,12)     , c2.appdata_id <> c1.appdata_id     , c2.customer_id = c1.customer_id ) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -