使用MySQL创建临时表时获得语法ERORR 1064
我一直在第2行中的创建表附近遇到语法错误。请对此我该怎么办。据我所知,我已经尝试并搜索到处搜索。
CREATE TEMPORARY TABLE #percentpopulationvaccinated
(
continent VARCHAR(200),
location VARCHAR(200),
date DATE,
population INT,
new_vaccinations NUMERIC,
currentPeopleVaccinated NUMERIC
)
INSERT INTO #percentpopulationvaccinated
SELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(CAST(vac.new_vaccinations as unsigned)) OVER (Partition By dea.location ORDER BY dea.location, dea.date) AS currentPeopleVaccinated
FROM portfolioproject.coviddeaths dea
INNER JOIN portfolioproject.covidvaccinations vac
ON dea.location = vac.location
AND dea.date = vac.date
WHERE dea.continent is not null
SELECT*, (currentPeopleVaccinated/population)*100
FROM #percentpopulationvaccinated
i keep getting syntax error near create table in line 2. Please what can i do about it. I have tried and search everywhere to my knowledge.
CREATE TEMPORARY TABLE #percentpopulationvaccinated
(
continent VARCHAR(200),
location VARCHAR(200),
date DATE,
population INT,
new_vaccinations NUMERIC,
currentPeopleVaccinated NUMERIC
)
INSERT INTO #percentpopulationvaccinated
SELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(CAST(vac.new_vaccinations as unsigned)) OVER (Partition By dea.location ORDER BY dea.location, dea.date) AS currentPeopleVaccinated
FROM portfolioproject.coviddeaths dea
INNER JOIN portfolioproject.covidvaccinations vac
ON dea.location = vac.location
AND dea.date = vac.date
WHERE dea.continent is not null
SELECT*, (currentPeopleVaccinated/population)*100
FROM #percentpopulationvaccinated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MySQL客户端对待
#
和与评论相同的行上的文本。据MySQL所知,您已经编写了此查询:临时表没有名称。难怪您有语法错误!
参见 https://dev.mysql.com/doc/doc/refman/8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. /en/comments.html 有关MySQL评论语法的信息。
The MySQL client treats
#
and the text that follows it on the same line as a comment. This means as far as MySQL knows, you have written this query:There is no name for the temporary table. No wonder you got a syntax error!
See https://dev.mysql.com/doc/refman/8.0/en/comments.html for information on MySQL's comment syntax.
尝试此命令以获取临时表:
Try this command for temporary tables: