我有以下php代码,工作正常:

$sql="UPDATE `fa` SET `group` = '27',`locked` = '1'  WHERE `send` LIKE '%Amazon%' AND `Locked` =0";
$result=mysqli_query($conn,$sql);
$sql="UPDATE `fa` SET `group` = '27',`locked` = '1'  WHERE `send` LIKE '%ebay%' AND `Locked` =0";
$result=mysqli_query($conn,$sql);
$sql="UPDATE `fa` SET `group` = '27',`locked` = '1'  WHERE `send` LIKE '%google%' AND `Locked` =0";
$result=mysqli_query($conn,$sql);

有没有办法把这些线排成一行?
只是为了清理代码。

最佳答案

您可以使用OR

update `fa`
set `group` = '27',
    `locked` = '1'
where (
        `send` like '%Amazon%'
        or `send` like '%ebay%'
        or `send` like '%google%'
        )
    and `Locked` = 0

关于php - 结合MySQL中的几个WHERE子句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42470219/

10-11 00:56