我需要从两个查询的联合创建一个表。
此查询完全符合我的要求:
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
一旦我添加了create语句,我就开始出错了
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)
错误是:
#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以便在'附近使用正确的语法(SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER' at line 1
答案 0 :(得分: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 all
SELECT portligh_lotteryTest.scores.team FROM portligh_lotteryTest.scores ORDER BY portligh_lotteryTest.scores.count ASC LIMIT 3)