Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql更新倍数为何不';这不管用吗?哦,还有php_Php_Mysql - Fatal编程技术网

mysql更新倍数为何不';这不管用吗?哦,还有php

mysql更新倍数为何不';这不管用吗?哦,还有php,php,mysql,Php,Mysql,我不明白为什么这不起作用,每一行一行的工作,但不是当我把他们连接在一起 mysql_query(" UPDATE imageProperties SET value='98' WHERE element='img1' AND property='left'; SET value='67' WHERE element='img1' AND property='top'; SET value='15' WHERE element='img1' AND property='width';

我不明白为什么这不起作用,每一行一行的工作,但不是当我把他们连接在一起

mysql_query("
 UPDATE imageProperties
  SET value='98' WHERE element='img1' AND property='left';
  SET value='67' WHERE element='img1' AND property='top';
  SET value='15' WHERE element='img1' AND property='width';
  SET value='15' WHERE element='img1' AND property='height';
  SET value='22' WHERE element='img2' AND property='left';
  SET value='49' WHERE element='img2' AND property='top';
  SET value='62' WHERE element='img2' AND property='width';
  SET value='75' WHERE element='img2' AND property='height';
");

我从对这个问题的回答中得到了这个想法

您正在用每个分号终止语句

这应该起作用:

mysql_query("
 UPDATE imageProperties
  SET value='98' WHERE element='img1' AND property='left';
 UPDATE imageProperties
  SET value='67' WHERE element='img1' AND property='top';
 UPDATE imageProperties
  SET value='15' WHERE element='img1' AND property='width';
 UPDATE imageProperties
  SET value='15' WHERE element='img1' AND property='height';
 UPDATE imageProperties
  SET value='22' WHERE element='img2' AND property='left';
 UPDATE imageProperties
  SET value='49' WHERE element='img2' AND property='top';
 UPDATE imageProperties
  SET value='62' WHERE element='img2' AND property='width';
 UPDATE imageProperties
  SET value='75' WHERE element='img2' AND property='height';
");

您正在用每个分号终止语句

这应该起作用:

mysql_query("
 UPDATE imageProperties
  SET value='98' WHERE element='img1' AND property='left';
 UPDATE imageProperties
  SET value='67' WHERE element='img1' AND property='top';
 UPDATE imageProperties
  SET value='15' WHERE element='img1' AND property='width';
 UPDATE imageProperties
  SET value='15' WHERE element='img1' AND property='height';
 UPDATE imageProperties
  SET value='22' WHERE element='img2' AND property='left';
 UPDATE imageProperties
  SET value='49' WHERE element='img2' AND property='top';
 UPDATE imageProperties
  SET value='62' WHERE element='img2' AND property='width';
 UPDATE imageProperties
  SET value='75' WHERE element='img2' AND property='height';
");

语法错误。您应该为每个集合更新imageProperties:

UPDATE imageProperties
  SET value='98' WHERE element='img1' AND property='left';
UPDATE imageProperties
  SET value='67' WHERE element='img1' AND property='top';
UPDATE imageProperties
  SET value='15' WHERE element='img1' AND property='width';

语法错误。您应该为每个集合更新imageProperties:

UPDATE imageProperties
  SET value='98' WHERE element='img1' AND property='left';
UPDATE imageProperties
  SET value='67' WHERE element='img1' AND property='top';
UPDATE imageProperties
  SET value='15' WHERE element='img1' AND property='width';

在一个station中使用CASE station进行尝试

   UPDATE imageProperties
   SET value= CASE when element='img1' AND property='left'   then '98' 
                   when element='img1' AND property='top'    then '67'
                   when element='img1' AND property='width'  then '15'
                   when element='img1' AND property='height' then '15'
                   when element='img2' AND property='left'   then '22'
                   when element='img2' AND property='top'    then '49'
                   when element='img2' AND property='width'  then '62'
                   when element='img2' AND property='height' then '75'
               ELSE `value`
               END

在一个station中使用CASE station进行尝试

   UPDATE imageProperties
   SET value= CASE when element='img1' AND property='left'   then '98' 
                   when element='img1' AND property='top'    then '67'
                   when element='img1' AND property='width'  then '15'
                   when element='img1' AND property='height' then '15'
                   when element='img2' AND property='left'   then '22'
                   when element='img2' AND property='top'    then '49'
                   when element='img2' AND property='width'  then '62'
                   when element='img2' AND property='height' then '75'
               ELSE `value`
               END


结合你得到的两个答案,你就得到了你需要知道的一切;)结合你得到的两个答案,你就得到了你需要知道的一切;)它不像第二行stillUPDATE imageProperties SET value='22',其中element='img3'和property='left';更新imageProperties设置值='49',其中元素='img3'和属性='top';更新imageProperties设置值='62',其中元素='img3'和属性='width';更新imageProperties集值='',其中元素='img3'和属性='height';您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,了解在'UPDATE imageProperties SET value='49'附近使用的正确语法,其中element='img3'和property='top';第2行的UPDA是您的DELIMETER“;”或其他什么?不-这不是必需的。可以使用单个update语句完成更新(请参见
CASE…WHEN
)。在任何情况下,如果您尝试将其作为单个查询提交,它将失败,因为它是一个多查询,
mysql_*()
不支持它(但是
mysqli_*()
支持它)。要么使用多个mysql_query()语句,要么在solutionIt不喜欢第二行stillUPDATE imageProperties SET value='22',其中element='img3'和property='left';更新imageProperties设置值='49',其中元素='img3'和属性='top';更新imageProperties设置值='62',其中元素='img3'和属性='width';更新imageProperties集值='',其中元素='img3'和属性='height';您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,了解在'UPDATE imageProperties SET value='49'附近使用的正确语法,其中element='img3'和property='top';第2行的UPDA是您的DELIMETER“;”或其他什么?不-这不是必需的。可以使用单个update语句完成更新(请参见
CASE…WHEN
)。在任何情况下,如果您尝试将其作为单个查询提交,它将失败,因为它是一个多查询,
mysql_*()
不支持它(但是
mysqli_*()
支持它)。使用多个mysql_query()语句或use CASE WHEN Solution确实有效,但它从“img3”、“img4”等栏中删除了该列其他单元格中的所有数据。您有img3和img4。好的,我将更新我的答案。我也可以执行多个案例吗?您可以尽可能多地执行有效的案例,但它删除了该列其他单元格中“img3”、“img4”等的所有数据。你有img3和img4,好的,我会更新我的回答。我可以处理多个案例吗?你可以尽可能多地处理案例