Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-29
1
Medium Priority
?
149 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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…

730 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