开发者

MYSQL update clause comparing the WHERE from 2 tables

开发者 https://www.devze.com 2022-12-11 06:09 出处:网络
$produpd = \"UPDATE tblnavpc SET tblnavpc.ChildName = tblnav.NavName \" . \"FROM tblnav WHERE tblnavpc.CID = tblnav.NavID\";
$produpd = "UPDATE tblnavpc SET tblnavpc.ChildName = tblnav.NavName " .
    "FROM tblnav WHERE tblnavpc.CID = tblnav.NavID";

This is the error I get"

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM tblnav WHERE tblnavpc.CID = tblnav.NavID' at line 1

I know keys aren't named greatly but I just trying to fix this one problem, I didn't 开发者_开发问答name the tables.


You don't have a FROM clause in an update:

UPDATE tblnavpc
INNER JOIN tblnav ON tblnavpc.CID = tblnav.NavID
SET tblnavpc.ChildName = tblnav.NavName


"From" cannot be used with update statements. Should be

$produpd = "UPDATE tblnavpc SET tblnavpc.ChildName = tblnav.NavName " .
    "WHERE tblnavpc.CID = tblnav.NavID";
0

精彩评论

暂无评论...
验证码 换一张
取 消