「SQL」in文と副問い合わせで複数の項目を使用する
書式
select * from テーブルA where(列名1,列名2,xx)
in (select 列名1、列名2 from テーブルB where 条件式)
使用例
select EmployeeID,LastName,FirstName,BirthDate,Photo from employees where (lastname, birthdate) in ( select lastname , birthdate from employees where birthdate like '196%' );
結果
EmployeeID | LastName | FirstName | BirthDate | Photo |
---|---|---|---|---|
1 | Davolio | Nancy | 1968-12-08 | EmpID1.pic |
3 | Leverling | Janet | 1963-08-30 | EmpID3.pic |