COMMUNITY FORUM
[SOLVED] SQL Query to UPDATE Extra Fields
- CuppaJoe
- Topic Author
- Offline
- New Member
- Share The Warmth
Less
More
10 years 6 months ago #126099
by CuppaJoe
Regards,
Joe,
ShareTheWarmth
[SOLVED] SQL Query to UPDATE Extra Fields was created by CuppaJoe
Hi Clever Peeps,
I wondered if someone might be able to assist me.
We have 1000s of K2 items, where the Extra Field data needs to be modified and I am struggling to be able to create a working query to update them, so wondered if someone could offer some guidance.
In my XXX_k2_items table, there is the extra_fields column.
This is currently populated with data such as:
I would like to run a query that updates XXX_k2_items and changes any extra_field column that contains "WIDGET" and change it to "WOGGLE".
I think I have confused myself too much :silly:
Many thanks in advance.
I wondered if someone might be able to assist me.
We have 1000s of K2 items, where the Extra Field data needs to be modified and I am struggling to be able to create a working query to update them, so wondered if someone could offer some guidance.
In my XXX_k2_items table, there is the extra_fields column.
This is currently populated with data such as:
[{"id":"42","value":"WIDGET"},
{"id":"17","value":"1"},
{"id":"18","value":"2"},
{"id":"20","value":"DATE1"},
{"id":"21","value":"DATE2"},
{"id":"35","value":"NUMBER1"},
{"id":"36","value":"NUMBER2"}]
I would like to run a query that updates XXX_k2_items and changes any extra_field column that contains "WIDGET" and change it to "WOGGLE".
I think I have confused myself too much :silly:
Many thanks in advance.
Regards,
Joe,
ShareTheWarmth
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 6 months ago #126100
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: SQL Query to UPDATE Extra Fields
Hi. There are two ways to do this:
1. Write a PHP script which will load one by one the items and update them.
2. Use an SQL query. This is simpler but it will replace all instances of the "WIDGET" word in your extra fields column. The query will look like:
Remember to backup your site first since this may affect other extra fields also.
1. Write a PHP script which will load one by one the items and update them.
2. Use an SQL query. This is simpler but it will replace all instances of the "WIDGET" word in your extra fields column. The query will look like:
UPDATE XXX_k2_items SET extra_fields = REPLACE(extra_fields, 'WIDGET', 'WOGGLE')
Remember to backup your site first since this may affect other extra fields also.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- CuppaJoe
- Topic Author
- Offline
- New Member
- Share The Warmth
10 years 6 months ago #126101
by CuppaJoe
Regards,
Joe,
ShareTheWarmth
Replied by CuppaJoe on topic Re: SQL Query to UPDATE Extra Fields
Hey Lefteris,
Wow, is it as simple as that . . . .
OK, time to back up a db and play.
I will be back with an update.
Wow, is it as simple as that . . . .
OK, time to back up a db and play.
I will be back with an update.
Regards,
Joe,
ShareTheWarmth
Please Log in or Create an account to join the conversation.
- CuppaJoe
- Topic Author
- Offline
- New Member
- Share The Warmth
10 years 6 months ago #126102
by CuppaJoe
Regards,
Joe,
ShareTheWarmth
Replied by CuppaJoe on topic Re: SQL Query to UPDATE Extra Fields
Hey Lefteris,
A big thank you!!!!
Yes that all works lovely and will save me a lot of item editing.
Thank you very much.
A big thank you!!!!
Yes that all works lovely and will save me a lot of item editing.
Thank you very much.
Regards,
Joe,
ShareTheWarmth
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 6 months ago #126103
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: SQL Query to UPDATE Extra Fields
You are welcome.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.