How would I do to select all videos that have upload_key = host with cnn in upload_value and send = 0
+----------+---------+------------+--------------+
| video_id | meta_id | upload_key | upload_value |
+----------+---------+------------+--------------+
| 1 | 6 | host | cnn |
| 1 | 7 | send | 0 |
+----------+---------+------------+--------------+
You can try below -
select video_id
from tablename where (upload_key,upload_Value) =('host','cnn')
and exists (select 1 from tablename where (upload_key,upload_Value)=('send','0'))
select all videos that have upload_key = host with cnn in upload_value and send = 0
One method is aggregation and having
:
select video_id
from t
where upload_key in ('host', 'send')
group by video_id
having sum( upload_key = 'host' and upload_value = 'cnn' ) > 0 and
sum( upload_key = 'send' and upload_value = '0' ) > 0;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.