开发者

Mysql replace row if value = something

I want to edit in 'videos' table, if 'category' column has the value set to 'Music' then开发者_Go百科 replace it with the value '1'.

How can i do this?


I'm a bit confused as to what you're trying to accomplish. Is 'category' a column that is currently set to 'Music' for some row, and you want to set that to 1? If so:

update videos set category = 1 where category = 'Music'


UPDATE videos
    SET category = '1'
    WHERE category = 'Music'


update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');


err

update videos set category="1" where category="Music"

Take a look at the mysql docs, they are really good with explanations and examples.


You want to replace the category with '1'?

update videos
set
  category = '1'
where
  category = 'Music'


Most probably the category your are referring to is a column, and not a row. If that is true then this solution is apt:

UPDATE videos SET category = '1' WHERE category = 'Music'

Go through the following link which contains tutorials, fruitful for beginners: http://msdn.microsoft.com/en-us/library/bb264565%28v=sql.90%29.aspx

With regards,

Jayesh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜