Solved

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

Posted on 2014-01-29
1
136 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 27

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

734 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