任何人都可以告诉我这段代码中的错误
$sql = "
UPDATE graduation
, classxii
, classx
SET university = '$university'
, college ='$college'
, course = '$course'
, branch = '$branch'
, year = '$year'
, school1 = '$school1'
, board1 = '$board1'
, percentage1 = '$percentage1'
, year1 = '$year1'
, school2 = '$school2'
, board2 = '$board2'
, percentage2 = '$percentage2'
, `year2 = '$year2'
WHERE graduation.email = '$email'
, classxii.email = '$email'
, classx.email = '$email'
";
错误:您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在'classxii.email
='rajdeep @ gmail.com',classx.email
='rajdeep@gmail.com''附近使用正确的语法
答案 0 :(得分:2)
多个条件需要与AND
或OR
相关联,而不是逗号。
$sql = "UPDATE `graduation`, `classxii`, `classx` SET
`university`='$university',`college`='$college',`course`='$course',`branch`='$branch',`year`='$year',
`school1`='$school1',`board1`='$board1',`percentage1`='$percentage1',`year1`='$year1',
`school2`='$school2',`board2`='$board2',`percentage2`='$percentage2',`year2`='$year2'
WHERE `graduation`.`email`='$email' AND `classxii`.`email`='$email' AND `classx`.`email`='$email'";
此外,将表名与列名分开的.
不得在反引号中。
您的表名或列名都不是保留字,因此您根本不需要所有这些嘈杂的反叛。
$sql = "UPDATE graduation, classxii, classx SET
university='$university',college='$college',course='$course',branch='$branch',year='$year',
school1='$school1',board1='$board1',percentage1='$percentage1',year1='$year1',
school2='$school2',board2='$board2',percentage2='$percentage2',year2='$year2'
WHERE graduation.email='$email' AND classxii.email='$email' AND classx.email='$email'";