简单的语法帮助新手

时间:2012-02-16 13:56:29

标签: mysql phpmyadmin

我已经搜索过,但没有找到任何类型的答案,但是当我在我的phpmyadmin中尝试它时,它告诉我语法错误。有人可以快速浏览一下,让我知道这可能有什么问题:

UPDATE wellness_rsform_properties 
WHERE PropertyName = 'REQUIRED' 
AND PropertyValue = 'NO' 
REPLACE  (PropertyValue, 'NO', 'YES');

我真的很感激任何反馈!

谢谢, 道格

6 个答案:

答案 0 :(得分:1)

UPDATE wellness_rsform_properties
SET PropertyValue = 'YES'
WHERE PropertyName = 'REQUIRED' AND PropertyValue = 'NO'

REPLACE功能不是必需的,因为您比较PropertyValue = 'NO'。如果您想将所有NO替换为YESREPLACE将适用:

UPDATE wellness_rsform_properties
SET PropertyValue = REPLACE (PropertyValue, 'NO', 'YES')
WHERE PropertyName = 'REQUIRED' AND PropertyValue like '%NO%'

答案 1 :(得分:1)

应该像

UPDATE wellness_rsform_properties 
SET PropertyValue = REPLACE('NO', 'YES') 
WHERE PropertyName = 'REQUIRED' AND PropertyValue = 'NO'

但是,您不需要使用替换,因为您知道列的新值,只需更新它:

UPDATE wellness_rsform_properties 
SET PropertyValue = 'YES' 
WHERE PropertyName = 'REQUIRED' AND PropertyValue = 'NO'

答案 2 :(得分:0)

UPDATE wellness_rsform_properties 
set PropertyValue = REPLACE (PropertyValue, 'NO', 'YES')
where PropertyName = 'REQUIRED' AND PropertyValue = 'NO';

答案 3 :(得分:0)

这应该做你似乎正在尝试的事情

UPDATE wellness_rsform_properties
SET PropertyValue = 'YES'
WHERE PropertyName ='REQUIRED'
AND PropertyValue = 'NO';

遵循语法

UPDATE <tables>
SET <field = value>
WHERE <criteria for which rows to update>

答案 4 :(得分:0)

你的意思是?

UPDATE wellness_rsform_properties 
SET PropertyValue = 'YES'
WHERE PropertyName = 'REQUIRED' AND PropertyValue = 'NO';

答案 5 :(得分:0)

UPDATE wellness_rsform_properties
SET PropertyValue = REPLACE(PropertyValue, 'NO', 'YES') 
WHERE PropertyName = 'REQUIRED' 
AND PropertyValue = 'NO';

我相信这就是你要找的东西。