Merging classificat...
 
Notifications
Clear all

Merging classifications via phpMyAdmin

5 Posts
3 Users
0 Reactions
1,761 Views
(@soundspretty)
Posts: 65
Trusted Member
Topic starter
 

I'm wanting to merge two classifications into one using phpMyAdmin. I guess this is more of a question on the phpMyAdmin script and not eFiction, but I was hoping that maybe someone out there would know the answer. I've managed to figure out how to change 1 into 2 in the classes field to update all stories with a classification of 1. But if a story has something like 1,3,5,7,9  in the classes field I don't know how to change it so that 1 will turn into 2 without affecting the other classifications.

Any ideas?


 
Posted : 07/03/2007 5:57 pm
Jan_AQ
(@jan_aq)
Posts: 1300
Noble Member
 

If I had to do that, I would try exporting the database table, and then doing a find and replace for the number. It can be very tricky and easy to mess up though...

So for changing a classification of 3 to 4, I would look for 3, and find the 3, including the coma, and change it to 4, or delete it. You have to be careful though, because it could change 33, to 34, as well, so for single diget numbers, I like to include the thing before them, a space, a comma ,3, ect...

Then I would export it back to the database.

It depeneds on how big your database is too... if you only have 50 stories, just edit each one individually.


Whoever said nothing is impossible never tried slamming a revolving door.

url: https://www.potionsandsnitches.org/fanfiction
php: 7.4.33 msql: 5.6.51-community GPL
efic version: 3.5.5 latest patches: yes
bridges: none mods: challenges, tracker, story end, beta, word

 
Posted : 08/03/2007 1:52 pm
(@soundspretty)
Posts: 65
Trusted Member
Topic starter
 

I thought about that, but I think it would be too easy to mistake categories for classes since the fields are so similar in how they display in the database. I've started going through and just changing it myself in the database, but it's so time consuming and I was hoping that there was a faster way. I have over 4k stories and I need to merge more than one classification so... ick.

Thanks though!


 
Posted : 08/03/2007 4:55 pm
(@jrabbit)
Posts: 64
Trusted Member
 

If XXX is your table and YYY is your field, AAA is your old number and BBB is your new number:


UPDATE XXX SET YYY = CASE
WHEN YYY='AAA' THEN 'BBB'
WHEN YYY LIKE '%,AAA' THEN concat(substr(YYY,1,length(YYY)-length(',AAA')),',BBB')
WHEN YYY LIKE 'AAA,%' THEN concat('BBB,',substr(YYY,length('AAA,')+1))
ELSE replace(YYY,',AAA,',',BBB,')
END;

Backup your database before changing anything and be VERY careful with the commas and quotes.


 
Posted : 08/03/2007 5:15 pm
(@soundspretty)
Posts: 65
Trusted Member
Topic starter
 

Works perfect! Thanks so much, this is going to save me a lot of time  πŸ˜€


 
Posted : 08/03/2007 8:36 pm
Share: