尝试在mysql查询中使用多个WHERE命令[Not Working]

时间:2014-09-29 02:46:38

标签: php mysql sql database sql-update

我有一个数据库,如果我的查询字符串与我指定的表的列值匹配,我想更改某个表的行值的状态。

这是我到目前为止所做的事情。

<?php

$connection = mysql_connect("localhost", "creative_db", "samplepassword");
$db = mysql_select_db("creative_dbgogo", $connection);

$slct = mysql_query("UPDATE zombie_links SET link_status = 'discard' WHERE link_url = '%pills%' OR link_url_title = '%pills%' OR link_title = '%pills%' OR link_title_url = '%pills%' OR link_content = '%pills%' OR link_summary = '%pills%' OR link_tags= '%pills%' ") or die(mysql_error());

?>

我做错了什么?请帮忙!

2 个答案:

答案 0 :(得分:1)

=不会使用通配符。我想你想要like

UPDATE zombie_links
    SET link_status = 'discard'
    WHERE link_url like '%pills%' OR link_url_title like '%pills%' OR link_title like '%pills%' OR
          link_title_url like '%pills%' OR link_content like '%pills%' OR
          link_summary like '%pills%' OR link_tags like '%pills%';

答案 1 :(得分:0)

试试这个

$slct = mysql_query("UPDATE zombie_links SET link_status = 'discard' WHERE link_url like '%pills%' OR link_url_title like '%pills%' OR link_title like '%pills%' OR link_title_url like '%pills%' OR link_content like '%pills%' OR link_summary like '%pills%' OR link_tags like '%pills%' ") or die(mysql_error());