2016-08-23 2 views
0

두 쿼리를 결합하여 테이블을 만들어야합니다. 내가 만드는 문을 추가하면 나는 오류유니온 쿼리에 대한 테이블 만들기 - 구문 오류

CREATE TABLE portligh_lotteryTest.cTop8 (team int) AS 
(SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER BY portligh_lotteryTest.scores.count DESC LIMIT 5) 
union 
(SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER BY portligh_lotteryTest.scores.count ASC LIMIT 3) 

오류가 얻을 시작

SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER BY portligh_lotteryTest.scores.count DESC LIMIT 5 
union 
SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER BY portligh_lotteryTest.scores.count ASC LIMIT 3 

:

#을

이 쿼리는 내가 그것을 필요로 정확하게 작동 1064 - SQL 구문에 오류가 있습니다. 근처 사용할 수있는 권리 구문에 대한 MySQL 서버 버전에 해당하는 설명서를 확인 당신은 쿼리 아래에 시도 할 수 있습니다 라인 1

+1

왜 당신은 select 문 주위에 괄호를 사용합니까? 필요하지 않습니다. – Shadow

+2

'uniol'이이 오타입니까? –

+0

위의 두 가지 모두 맞습니다. 그림자 괄호 바깥 쪽 세트를 제거한 다음 uniol에서 오류가 발생했습니다. –

답변

0

에서 '(portligh_lotteryTest.scores 순서와 portligh_lotteryTest.scores.team 선택': -

CREATE TABLE portligh_lotteryTest.cTop8 (team int) AS 
(SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER BY portligh_lotteryTest.scores.count DESC LIMIT 5 
union all 
SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER BY portligh_lotteryTest.scores.count ASC LIMIT 3) 
관련 문제