DB Replacer

Replacing a column value with another

8 months 1 week ago #77952

Ahmed Balfaqih's Avatar Ahmed Balfaqih

Hi,

I cannot afford to experiment now and get it wrong, so here is my question.

I have a column called sales_person and the value stored is an integer.

So how do I change the value of in table of all those records that has it sales_person = 7 to sales_person = 5, for example.

Thank you.

8 months 1 week ago #77954

Peter van Westen's Avatar Peter van Westen Admin

You can use the WHERE field to limit down the results to only the ones you want:

sales_person = 7

Then you can use the '*' to make it match (and therefor replace) the entire value.

8 months 1 week ago #77955

Peter van Westen's Avatar Peter van Westen Admin

8 months 1 week ago #77956

Ahmed Balfaqih's Avatar Ahmed Balfaqih

Peter van Westen wrote:


I did. But since I am so scared that I screw up and the data is important, I thought of asking first. In fact, I made a back up now of the whole site, and I will experiment in the back site. Just in case.

8 months 1 week ago #77958

Peter van Westen's Avatar Peter van Westen Admin

Yes, always make a backup before messing about in the database.

8 months 1 week ago #77959

Ahmed Balfaqih's Avatar Ahmed Balfaqih

Peter van Westen wrote:

You can use the WHERE field to limit down the results to only the ones you want:
sales_person = 7

Then you can use the '*' to make it match (and therefor replace) the entire value.

Peter, you made doing repetitive stuff so easy. It worked like a charm. I knew it is not going to be hard, but I lost so many hours doing fixing issues I did not want to waste my time making a mistake.

Thank you and have a wonderful weekend.

8 months 1 week ago #77960

Peter van Westen's Avatar Peter van Westen Admin

;)

You too.