我有 2 张桌子
收藏夹表
----------------------------------------------------------------------
| FavouritesID | CompanyID | CustomerID | ProfilePhoto | CompanyName |
----------------------------------------------------------------------
| |
| |
| |
----------------------------------------------------------------------
配置文件表
-------------------------------------------
| CompanyID | CompanyName | ProfilePhoto |
-------------------------------------------
| 1 | Nike |http://loca.. |
| 2 | Adidas |http://loca.. |
| 3 | PaulSmith |http://loca.. |
-------------------------------------------
我想使用 INSERTCompanyName
并ProfilePhoto
进入收藏夹表CompanyID
因此,当将一行插入收藏夹表 ex CompanyID=1 时,CompanyName=Nike
将ProfilePhoto=htpp://local...
插入收藏夹表,从配置文件表中获取信息。
这是我到目前为止所拥有的:
CREATE TRIGGER `Favourites` BEFORE INSERT ON `Favourites`
FOR EACH ROW BEGIN
INSERT INTO Favourites SET ProfilePhoto = (SELECT ProfilePhoto FROM Profile WHERE NEW.CompanyID = CompanyID);
END
我的代码中有哪些错误?这没用