View Single Post
winterghost
Member
Join Date: Dec 2012
Old 04-24-2013 , 20:25   Re: A SQL code to run to add additional options in 'attrs' field.
Reply With Quote #9

Quote:
Originally Posted by vodka00 View Post
This set all attrs fields that were in equipment to 0.
Yeah I checked it in SQL fiddle. Soon as I try to place alongub's SQL code in, this error appears:

Schema Creation Failed: Data truncation: Truncated incorrect DOUBLE value: ', "lifetime": 0.5, "width": 15, "endwidth": 3, "fadelength": 5, }':

From what I could see, the + operator is replaced by CONCAT in MySQL? So for a MySQL database the correct SQL statement would be:
Code:
UPDATE store_items SET attrs = CONCAT(LEFT(attrs, Length(attrs) - 1), ', "lifetime": 0.5, "width": 15, "endwidth": 3, "fadelength": 5, }') WHERE type = 'equipment';
That would appear to work - check the SQL Fiddle(http://sqlfiddle.com/#!2/666ae/1)
__________________
winterghost is offline