Baibs
Baibs

Reputation: 33

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). Is there some HAVING condition I can write? Or maybe just AND condition?

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

the table modell looks like this

Upvotes: 0

Views: 893

Answers (1)

Jayvee
Jayvee

Reputation: 10875

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<>''

Upvotes: 1

Related Questions