before

SELECT * from(
(
SELECT 
  a.no,
  a.code,
  b.price,
  b.start_date,
  b.end_date
FROM product a
left join sale b
on a.code = b.code
)
Union
(
SELECT 
  a.no,
  a.code,
  b.price,
  b.start_date,
  b.end_date
FROM product a
right join sale b
on a.code = b.code
order by no desc
)
)
where code not in ('9001')
order by code, start_date

 

이 때 Error Code: 1248 Every derived table must have its own alias 오류가 발생한다.

 

파생테이블에 명칭( alias )가 있어야한다.

 

after

SELECT * from(
(
SELECT 
  a.no,
  a.code,
  b.price,
  b.start_date,
  b.end_date
FROM product a
left join sale b
on a.code = b.code
)
Union
(
SELECT 
  a.no,
  a.code,
  b.price,
  b.start_date,
  b.end_date
FROM product a
right join sale b
on a.code = b.code
order by no desc
)
)as c
where code not in ('9001')
order by code, start_date

WRITTEN BY
beautifulhill

,