У меня проблемы с формулировкой юридического заявления, чтобы удвоить статус поставщиков (поставщиков), которые отправили (sp) более 500 единиц.
Я пытался:
update s
set s.status = s.status * 2
from s join sp
on (sp.sno = s.sno)
group by sno
having sum(qty) > 500;
однако я получаю эту ошибку от Mysql:
ERROR 1064 (42000): 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
'from s join sp on (sp.sno = s.sno) group by sno having sum(qty) > 500' at line 1
У кого-нибудь есть идеи о том, что не так с этим запросом? Вот моя схема:
create table s
( sno char(5) not null,
sname char(20) not null,
status smallint,
city char(15),
primary key (sno)
);
create table p
( pno char(6) not null,
pname char(20) not null,
color char(6),
weight smallint,
city char(15),
primary key (pno)
);
create table sp
( sno char(5) not null,
pno char(6) not null,
qty integer not null,
primary key (sno, pno)
);