I don't understand why this won't work, each line one by one works but not when I join them together...
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';
");
I got the idea from the answer to this question here
syntax is wrong.you should have UPDATE imageProperties for each set:
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';
try it by using CASE statment in one statment.
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
You are terminating the statement with each semicolon.
This should work:
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';
");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.