1

Please see the details of this question: phrase split algorithm in PHP

I want to do something similar to this question, but in MySQL instead of PHP...

I have a string in a table:

SELECT `string` FROM `strings`;

----------------------
        string
----------------------
"Today is a great day"
----------------------

What I want to do is this:

CREATE TEMPORARY TABLE `phrases`
SELECT `phrase` FROM (.. All possible phrases in table `strings`)

And then I'd be left with this temporary table:

SELECT `phrase` FROM `phrases`;

-------------------------------
             phrase
-------------------------------
today
today is
today is a
today is a great
today is a great day
is
is a
is a great
is a great day
a
a great
a great day
great
great day
day
-------------------------------

So basically the same as the question I referenced but in MySQL.

5
  • Any particular reason you want to do this on the database side? Commented Dec 20, 2011 at 21:18
  • why wouldn't you take the results of the PHP implementation and push the into the database? Commented Dec 20, 2011 at 21:19
  • I'm dealing with a lot of rows.It's slow to get the data out of the database and then put it back in again. The original strings are already in the database, and I want to get the new sub strings into the database aswell, so doing it all in the db will cut out the transfer. Commented Dec 20, 2011 at 21:23
  • Is there a reason you're not using fulltext searches instead? Commented Dec 21, 2011 at 1:08
  • @Kenaniah: Thanks for your comment, I didn't realize fulltext searches would help with this. I've managed to solve my problem with PHP alone now, but it may benefit others if you post an answer using fulltext. Commented Dec 22, 2011 at 1:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.