在mysql数据库中有一个名为jobsposts的表。我试图在当前jobpost表中发生更新后将数据插入另一个表(jobrequest)。
这是我的sql表和查询。
DELIMITER //
CREATE DEFINER=`root`@`localhost` TRIGGER
trg_jobPost_after_update
AFTER UPDATE ON jobPost
FOR EACH ROW
BEGIN
INSERT INTO jobRequest (userID, name, email, phoneNo,
location, jobID,
title, level, dateFrom, dateTo, description,
jobStatus, emailTeacher, nameTeacher,
locationTeacher, phoneNoTeacher, cv, gardavetting,
linkedin)
SELECT
jobPost.userID
, jobPost.name
, jobPost.email
, jobPost.phoneNo
, jobPost.location
, jobPost.jobID
, jobPost.title
, jobPost.level
, jobPost.dateFrom
, jobPost.dateTo
, jobPost.description
, users.nameTeacher
, users.locationTeacher
, users.phoneNoTeacher
, users.cv
, users.gardavetting
, users.linkedin
, NEW.jobStatus
, NEW.emailTeacher
FROM jobPost
WHERE jobPosts.emailTeacher = NEW.emailTeacher;
END //
DELIMITER ;
表-
jobpost表
用户表
jobrequest表
1条答案
按热度按时间jv4diomz1#
从评论来看,似乎你只是需要一个
Inner Join
在jobPost
以及users
table,开着emailTeacher
.还有,来自
Select
与之相比Insert
条款;我已按正确的顺序添加了它们。