我正在尝试从skills_jobs表中删除一行
以下是我的查询
delete from skills_jobs skj inner join jobs j on skj.jobid=j.id inner join users u on u.id=j.userid where u.id=$userid
但它会引发以下错误;
致命错误:未捕获的异常'异常',消息'你有一个 SQL语法错误;查看与您的手册相对应的手册 MySQL服务器版本,用于在'skj内连接附近使用正确的语法 作业j在skj.jobid = j.id内部加入用户你在u.id = j.userid wher'at 第1行查询:从技能_jobs skj内部联接作业j中删除 skj.jobid = j.id内部联接用户你在u.id = j.userid其中u.id = 41
答案 0 :(得分:2)
您必须设置表,从中删除行,然后尝试:
DELETE skills_jobs from skills_jobs INNER JOIN jobs j ON skills_jobs.jobid=j.id INNER JOIN users u ON u.id=j.userid WHERE u.id=$userid
参见"多表删除"来自https://dev.mysql.com/doc/refman/5.7/en/delete.html
答案 1 :(得分:1)
应该是这样的
skills_jobs skj inner join jobs j on skj.jobid=j.id
你忘记了语法
所以正确的语法如下所示: -
delete from skills_jobs skj inner join jobs j on skj.jobid=j.id inner join users u on u.id=j.userid where u.id=$userid
希望这有帮助!
答案 2 :(得分:1)
delete from skills_jobs skj
inner join jobs j ON skj.jobid=j.id
inner join users u ON u.id=j.userid
where u.id=$userid
尝试以上代码。 希望这会有所帮助。
答案 3 :(得分:1)
DELETE FROM skills_jobs skj INNER JOIN jobs j ON j.id=skj.jobid INNER JOIN
users u ON u.id=j.userid
WHERE u.id=$userid
答案 4 :(得分:1)
DELETE FROM skj USING `skills_jobs` AS skj
INNER JOIN `jobs` AS j ON skj.`jobid` = j.`id`
INNER JOIN `users` AS u ON u.`id` = j.`userid`
WHERE u.`id` = $userid
如果声明表的别名,则在引用表时必须使用别名。
另一个有条理的答案:
DELETE skj FROM `skills_jobs` AS skj
INNER JOIN `jobs` AS j ON skj.`jobid`=j.`id`
INNER JOIN `users` AS u ON u.`id`=j.`userid`
WHERE u.`id`=$userid