0

I want to edit in 'videos' table, if 'category' column has the value set to 'Music' then replace it with the value '1'.

How can i do this?

2
  • You need to provide more information.. what is the table definition? it seems like you're confusing rows with columns, and which value do you want replaced? Commented Jun 9, 2011 at 19:07
  • yes, i confused rows with columns. my bad. Commented Jun 9, 2011 at 19:14

6 Answers 6

1

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'
Sign up to request clarification or add additional context in comments.

1 Comment

yes, this was what i want to say. 'category' is a column, sorry thank you, it worked.
1
UPDATE videos
    SET category = '1'
    WHERE category = 'Music'

Comments

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

Comments

1

err

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

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

Comments

1

You want to replace the category with '1'?

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.