I have a query:
SELECT s.period, s.year, s.amount
FROM salaries s
I would like to select from salaries
table only the rows th
You can use more than one column for an IN
condition:
SELECT s.period, s.year, s.amount
FROM salaries s
where (s.year, s.period) in (select year, period from periods)
But Gordon's not exists
solution is probably faster.
Try this:
SELECT s.period, s.year, s.amount FROM salaries s
where s.period in (select period from periods)
and s.year in (select year from periods)
Does this work with your environment?
WHERE EXISTS (SELECT 1
FROM periods p
WHERE p.period = s.period AND p.year = s.year
)