In MySql, Let’s say I have a table
myTable
ID
word
I would like to insert a string into the table, but have each word from the string insert on a seperate row.
For example, if I have a string…
“The quick brown fox jumped”
…it would be inserted like so:
myTable
1 - The
2 - quick
3 - brown
4 - fox
5 - jumped
I am wondering if it is possible to write an sql query that can do this, given the string? Or do I have to parse up the string beforehand?
Thanks (in advance) for your help
You may be able to work some odd magic using
SUBSTRING INDEX()but I don’t think it would be pretty. In addition, it would require you to know the indices prior to theInsert. I would recommend parsing prior to the insert. Check the MySQL 5.0 Reference specific toStringfunctions.