with
cte1 as (select a, b from table 1),
cte2 as (select c, d from table 2), ...
select a from cte1
select b, d from cte1 join cte2
where cte1.a = cte2.c;
-- 예시쿼리
with dept as
(select department_id, department_name, dept_name
from departments) -- 임시 테이블 생성
select a.employee_id as em_id,
a.first_name||' '||a.lastname as name
from employees as a, dept b
where a.department_id = b.department_id;
참고문서
MySQL docs