MySQL更新语句返回没有受影响的行

时间:2015-07-16 03:04:58

标签: php mysql

我很难在此找到错误。我正在通过PHP在MySQL中运行Update命令。

UPDATE `diary` SET `meds_taken` = 'Y' AND `time_taken` = '9AM' AND 
`stress_level` = '7' AND `adverse` = 'N' AND `events` = 'testing' AND 
`journal_date` = '2015-07-14' AND `submit_time` = NOW() WHERE `hash` = 
'a9fc195dc62624db5fddd7134392ce67'

它不会返回任何错误,但会影响0行。直接在PHPMyAdmin中运行命令具有相同的效果。

要确认,有一行包含哈希:

SELECT * FROM `diary` WHERE `hash` = 'a9fc195dc62624db5fddd7134392ce67'

产生一排。所有更新的列都是VARCHAR类型,但“{1}}类型的”事件“和TEXT类型的”submit_time“除外。

我觉得我在某处弄错了但找不到它

1 个答案:

答案 0 :(得分:1)

尝试逗号,而不是AND:

UPDATE `diary`
SET `meds_taken` = 'Y',
    `time_taken` = '9AM',
    `stress_level` = '7',
    `adverse` = 'N',
    `events` = 'testing',
    `journal_date` = '2015-07-14',
    `submit_time` = NOW()
WHERE `hash` = 'a9fc195dc62624db5fddd7134392ce67';