Solved

wordpress - sql query - comments table - replace mutiple words with random words

Posted on 2014-01-29
1
119 Views
Last Modified: 2014-09-19
On wordpress 3.8

on comments table

What sql query will replace

by choose words randomly

word1 replaced with {word2|word3|word5}
word6 replaced with {word7|word8|word9}


P.S.

I have 10 questions, highest point level - open about sql queries

Soo, Lots of points for an sql guy
0
Comment
Question by:Matt_Walker01
1 Comment
 
LVL 26

Accepted Solution

by:
Zberteoc earned 500 total points
ID: 39820918
Assuming you have 3 replaceing words to choose from you can use:
UPDATE your_table SET 
	your_field = 
		case FLOOR(RAND() * (3)) + 1
			when 1 then REPLACE(your_field, 'word1', 'word2')
			when 2 then REPLACE(your_field, 'word1', 'word3')
			when 3 then REPLACE(your_field, 'word1', 'word5')
		end
WHERE <condition_here

Open in new window

Similarly you will proceed with the replace for the word6
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL Init Waits 25 85
WordPress - How to identify incomplete registrations? 4 28
WordPress Themes 10 35
mysql update statement 3 7
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now