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
'프로그래밍 > SQL' 카테고리의 다른 글
mysql- Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. (0) | 2019.12.14 |
---|---|
outer join - mysql (0) | 2019.11.28 |
workbench에서 readonly 해제하기 (0) | 2019.11.28 |
mysql - "Error Code : 1221 Incorrect usage of UNION and ORDER BY" (0) | 2019.11.22 |
mysql workbench에서 BLOB 타입 데이터 안나올 때 (0) | 2019.11.12 |
WRITTEN BY
,