数据库中create table temp ( city char(16) not null, qtysum float ) insert into temp(city, qtysum) select s.city, SUM(qty) from s, spj where s.sno = spj.sno and (s.city = '上海' or s.city = '天津') group by s.city出现[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into temp(city, qtysum)' at line 6怎么办
时间: 2023-12-17 18:05:55 浏览: 66
这个错误是因为在使用多条 SQL 语句时没有正确分隔它们。你需要在两条 SQL 语句之间添加分号 (;)。
正确的 SQL 语句应该是这样的:
```
create table temp (
city char(16) not null,
qtysum float
);
insert into temp(city, qtysum)
select s.city, SUM(qty)
from s, spj
where s.sno = spj.sno and (s.city = '上海' or s.city = '天津')
group by s.city;
```
注意,在 `create table` 和 `insert into` 语句之间添加了分号。这样就可以正确执行 SQL 语句了。
阅读全文