Site:Developer stuff/Manipulating text within the commentary pages
From Feast upon the Word (http://feastupontheword.org). Copyright, Feast upon the Word.
Here is some code that was used to manipulate the text within the commentary pages. This was run against the site not too long after its initial creation.
--Change "Thought Questions" to "Questions" update cur set cur_text = concat( left( cur_text , instr( cur_text , '== Thought questions ==' ) - 1 ) , '== Questions ==' , SUBSTRING( cur_text , instr( cur_text , '== Thought questions ==' ) + 23 ) ) where cur_text LIKE '%== Thought questions ==%' --Move exegesis after lexical notes (before lexical notes came after the exegesis section. update cur set cur_text = concat( left( cur_text , instr( cur_text , '== Exegesis ==' ) - 1 ), SUBSTRING( cur_text , instr( cur_text , '== Lexical notes ==' ), instr( cur_text , '== Related links ==' ) - instr( cur_text , '== Lexical notes ==' ) ), SUBSTRING( cur_text , instr( cur_text , '== Exegesis ==' ), instr( cur_text , '== Lexical notes ==' ) - instr( cur_text , '== Exegesis ==' ) ), SUBSTRING( cur_text , instr( cur_text , '== Related links ==' ) ) ), cur_timestamp=20050412042908, cur_touched=20050412042908, inverse_timestamp=79949587957091 where cur_text LIKE '%== Lexical notes ==%' ---------------------------------- --Other random stuff. ---------------------------------- --This query will select the text before the exegesis. SELECT cur_id, left( cur_text , instr( cur_text , '== Exegesis ==' ) - 1 ) FROM cur_test WHERE cur_text LIKE '%== Lexical notes ==%' -- This selects the text of the Lexical Notes. SELECT cur_id, SUBSTRING( cur_text , instr( cur_text , '== Lexical notes ==' ), instr( cur_text , '== Related links ==' ) - instr( cur_text , '== Lexical notes ==' ) ) FROM cur_test WHERE cur_text LIKE '%== Lexical notes ==%' --This selects the text of the exegesis SELECT cur_id, SUBSTRING( cur_text , instr( cur_text , '== Exegesis ==' ), instr( cur_text , '== Lexical notes ==' ) - instr( cur_text , '== Exegesis ==' ) ) FROM cur_test WHERE cur_text LIKE '%== Lexical notes ==%' --This selects the text after the related links. SELECT cur_id, SUBSTRING( cur_text , instr( cur_text , '== Related links ==' )) FROM cur_test WHERE cur_text LIKE '%== Lexical notes ==%'