简体   繁体   English

Select 值仅当另一个表中的值存在时 - SQL Oracle

[英]Select values only if values in another table exist - SQL Oracle

Can you help me please?你能帮我吗? Trying to select those article numbers and pic paths that has the picture (some of them are without but it is not null).尝试 select 那些具有图片的文章编号和图片路径(其中一些没有但它不为空)。 Is there some HAVING condition I can write?我可以写一些 HAVING 条件吗? Or maybe just AND condition?或者也许只是 AND 条件?

select a.artnr, p.path
from article a, photo p
where a.artnr = p.photo_nr
having ...and ...(?);

表模型看起来像这样

if you are looking for paths that are not empty, then you should do this:如果您正在寻找不为空的路径,那么您应该这样做:

select a.artnr, p.path
from article a
join photo p on a.artnr = p.artnr_nr
where p.path <> ''

If you have to do it in the very old school way using commas, which I agree with the comments that is not a good practice, then如果您必须使用逗号以非常古老的方式进行操作,我同意这不是一个好习惯的评论,那么

select a.artnr, p.path
from article a, photo p
where a.artnr = p.artnr_nr
and p.path<>''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM