这是我的数据库:
我的目标是检索包含所有admin_ngp
以及仅yes
旁边的admin_ngp
的所有行。类似这样的事情:
我觉得简单的相交操作就足以得到我的结果。但是,我无法获得理想的结果。这是我的查询:
SELECT *
FROM artist_list
WHERE uploaded_by = 'admin_ngp' IN (SELECT *
FROM artist_list
WHERE changed_by_admin = 'yes')
答案 0 :(得分:0)
You could use an OR in your where:
SELECT *
FROM artist_list
WHERE (uploaded_by = 'admin_ngp' AND name='admin_ngp' AND bio='admin_ngp')
OR (changed_by_admin = 'yes' AND uploaded_by = 'admin_ngp')
答案 1 :(得分:0)
不要想太多。我想这就是您所需要的。
SELECT *
FROM artist_list
WHERE
uploaded_by = 'admin_ngp' and changed_by_admin = 'yes'
;
答案 2 :(得分:0)
尝试一下
案例1 如果您要upload_by为'admin_ngp',则changed_by_admin应该为'yes'或名称和bio应该为'admin_ngp'
SELECT *
FROM artist_list
WHERE Case when uploaded_by = 'admin_ngp' and changed_by_admin = 'yes'then 1 when name = 'admin_ngp' and bio = 'admin_ngp' then 1 else 0 end = 1
案例2 如果您希望upload_by为'admin_ngp',则changed_by_admin应该为'yes',或者name或bio应该为'admin_ngp'
SELECT *
FROM artist_list
WHERE Case when uploaded_by = 'admin_ngp' and changed_by_admin = 'yes'then 1 when name = 'admin_ngp' then 1 when bio = 'admin_ngp' then 1 else 0 end = 1