以下是我在同一个表中更新值的SQL查询。我想将这两个查询嵌入一个,我无法做到这一点。请让我知道我该怎么做,谢谢:
$SQL1 = "UPDATE table1 SET gender='$sex', dob = '$dob', reg_date ='$reg_date'
WHERE id = '$id'"
$SQL2 = "UPDATE table1 a CROSS JOIN lookup b
SET a.ADRES = REPLACE(a.ADRES, b.`WRONG`, b.`RIGHT`)
WHERE a.ADRES LIKE CONCAT('%', b.`WRONG`, '%')"
答案 0 :(得分:1)
UPDATE table1 a CROSS JOIN lookup b
SET a.ADRES = REPLACE(a.ADRES, b.`WRONG`, b.`RIGHT`),
gender='$sex',
dob = '$dob',
reg_date ='$reg_date'
WHERE a.ADRES LIKE CONCAT('%', b.`WRONG`, '%') OR
id = '$id'
该查询容易被SQL Injection
攻击,请参阅下面的文章,了解如何保护它,