Vote count:
0
I am new to SQL and triggers, so my question might be an easy one, but after a lot of searching I am not sure how to do it.
So, I have one table with players. When a player is created, I want to copy the new data to 2 tables. Some of the fields go to Product, and some into Product Description.
The problem is I can't make it insert the info in the second table (product description) with the trigger. I read that I can't use multiple triggers for the same operation, so I need to do it with one.
Here is the code I've come so far:
BEGIN
INSERT INTO product (product_id, manufacturer_id)
SELECT player.id,player.team_id
FROM player WHERE NOT EXISTS (SELECT * FROM product
WHERE product.product_id = player.id);
INSERT INTO product_description (product_id, name, description)
SELECT player.id,CONCAT_WS(' ',player.first_name,player.last_name),player.about
FROM player WHERE NOT EXISTS (SELECT * FROM product
WHERE product.product_id = player.id);
END
Any help will be appreciated.
Thanks :)
asked 44 secs ago
Insert data in multiple tables with one trigger
Aucun commentaire:
Enregistrer un commentaire