Mysql - dynamic SQL not allowed in trigger
问题 I want to create a trigger with dynamic SQL where I get a column name from a variable. Here is my simplified mysql schema: CREATE TABLE products (id int); INSERT INTO products VALUES (1),(2); CREATE TABLE attribute_values (product_id int, `key` varchar(100), value varchar(100)); INSERT INTO attribute_values VALUES ( 1, 'title', 'Orange'), ( 1, 'code', 'O125'), ( 2, 'title', 'Pizza'); CREATE TABLE product_attributes SELECT products.id, MAX(CASE WHEN attribute_values.key = 'title' THEN