我正在尝试触发更新我的产品状态的操作。交付后。因此,当在entrega_viaturas
中插入内容时,它会触发并更新estado
中的viatura
。
这是触发器的表和代码,如果发现错误,请告知。
Tabel entrega_viaturas(id_entrega,data_entrega,funcionario,viatura(fk id_viatura))
Tabel viatura(id_viatura,estado,*other columns*)
CREATE TRIGGER `Update_Status` AFTER INSERT ON `entrega_viaturas`
FOR EACH ROW BEGIN
AS
begin
update viatura
SET estado='Indisponivel'
Where viatura.id_viatura = entrega_viaturas.viatura
end
但是它说entrega_viaturas.viaturas是一个未知列。帮助
答案 0 :(得分:1)
我假设您打算使用select DISTINCT country as country,json_query((select CONCAT('[','"', STRING_AGG(city, '","'), '"',']')
from test b
where b.country=a.country
)) as city
from test a
for json path
:
new