where子句触发器中的未知表

时间:2019-12-02 15:24:32

标签: mysql sql

我正在尝试触发更新我的产品状态的操作。交付后。因此,当在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是一个未知列。帮助

1 个答案:

答案 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