Two columns in subquery in where clause

前端 未结 3 730
闹比i
闹比i 2021-01-05 16:20

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

3条回答
  •  耶瑟儿~
    2021-01-05 16:41

    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.

提交回复
热议问题