SQL guru corner

A section to discuss matters not related to Chess in particular.
User avatar
John Upham
Posts: 7215
Joined: Wed Apr 04, 2007 10:29 am
Location: Cove, Hampshire, England.

SQL guru corner

Post by John Upham » Sun Oct 24, 2010 12:04 pm

As I'm feeling a little bunged up and lazy today I thought I'd seek some SQL expertise in forum land...

I am normalising and standardising the 1,000 or so CoM questions and want to make some global edits on all of the text fields for each question and answer (five answers for each question).

All of the questions are in one table and each one has text (as well as a diagram as a BLOB) associated with it.

For each question I want to replace, for example, "black" with "Black".

I could write PHP code to do this but I'm hoping there is an SQL method for doing this.

Your help would be much appreciated!
British Chess News : britishchessnews.com
Twitter: @BritishChess
Facebook: facebook.com/groups/britishchess :D

User avatar
Carl Hibbard
Posts: 6028
Joined: Fri Dec 08, 2006 8:05 pm
Location: Evesham

Re: SQL guru corner

Post by Carl Hibbard » Sun Oct 24, 2010 12:33 pm

Something like..

update questions set answer=replace(answer,'black','Black')

However I am on an iPad not a PC so take a backup first as that is off the top of my head
Cheers
Carl Hibbard

User avatar
John Upham
Posts: 7215
Joined: Wed Apr 04, 2007 10:29 am
Location: Cove, Hampshire, England.

Re: SQL guru corner

Post by John Upham » Sun Oct 24, 2010 12:44 pm

I'd just found the REPLACE function when your post landed!

Thanks Carl! :D
British Chess News : britishchessnews.com
Twitter: @BritishChess
Facebook: facebook.com/groups/britishchess :D

User avatar
Carl Hibbard
Posts: 6028
Joined: Fri Dec 08, 2006 8:05 pm
Location: Evesham

Re: SQL guru corner

Post by Carl Hibbard » Sun Oct 24, 2010 12:47 pm

I might have answered quicker but Angry Birds Halloween is more important!!
Cheers
Carl Hibbard