Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    74

    Unanswered: How to split string with delimiter ?

    Hi All,

    can someone guide me how can i split the string with delimiter ?

    ie : budget, hotel, Test

    how can i use "," as delimiter so that the query can return me with 3 separate string like

    result : budget
    hotel
    Test

    Thank you !

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    since you weren't very clear on what you're doing and why, i shall give you the answer without any sort of example of usage --

    use the SUBSTRING_INDEX function

    pulling the first word is easy, pulling the last word is easy (using -1 as the count), and pulling any of the words in between will require nested invocations

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2004
    Posts
    74
    Hi r937,

    the purpose of doing so is to get count on the frequency of similar words to create tag cloud.

    can you please enlighten me on how i can use neted invocation, are you imply using while loop and using following condition as filter

    1.Scan character by character to check if there have any ","
    2.if "," found then substring
    3.if no "," found, then return the only word

    if the above condition make sense, how can i scan character by character to find "," ?

    thank you !

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    okay, now that i see what you're doing, i realize that it isn't going to be 3 words all the time, is it

    you should do this entire process (analysis of words) outside of mysql

    for one thing, this will give you much better power over which words to ignore

    save each good word in a separate table, with a link to the article that the word is found in
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Mar 2004
    Posts
    74
    Yup r937,

    it doesn't fix it with lenght of 3 words, i just need to find a way how i can get a word from a string like that

    When i extract one word, i will do a insertion to a temporary table and keep repeat until all string are parse.

    then only i start count on the frequency.

    my first challenge here is to find out how i can scan each "," in a whole string.

    thank you !

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    like i said, do ~not~ attempt to do this with mysql
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •