我想要合并两个MySQL查询,当我直接将它们输入phpmyadmin时,它可以正常工作。 我得到这样的查询:
$sqlCombine = $sqlStart.";".$sqlStartBefore;
$conn->query($sqlCombine);
echo $sqlCombine;
echo给出以下内容:
UPDATE rn_slots_availability SET slot_avail_noclean = slot_avail_noclean -1 WHERE hotel_id = '5' AND room_type_id = '6' AND slot_date = '2014-09-05';UPDATE rn_slots_availability SET slot_avail_clean = slot_avail_clean -1 WHERE hotel_id = '5' AND room_type_id = '6' AND slot_date = '2014-09-06'
复制/粘贴到phpmyadmin就像一个魅力,直接执行没有,给出以下错误:
Error: 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 'UPDATE rn_slots_availability SET slot_avail_clean = slot_avail_clean -1 WHERE ho' at line 1
这是第二个查询,但我不明白为什么?
答案 0 :(得分:1)
由于某种原因,您当前的配置不支持多查询。如果你不关心你执行它们的方式,那么就像这样一次做一个查询:
$conn->query($sqlStart);
$conn->query($sqlStartBefore);
错误应该消失。