Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Location
    Vancouver Canada
    Posts
    26

    Unanswered: Pattern matching?

    I have some data I want to pull out of one field and put into another. The tricky part is that the field the data is in is a text field, and the data could be anywhere in there. So I need to do some sort of pattern matching to find it.

    Here is an example of the query I want to run, but I don't know what to put for the question mark.

    UPDATE Building SET architect = ? WHERE description LIKE '%Architect: %';


    In the description field, architects are in this format:

    Architect: name of architect
    or
    Architect: name of architect, http://example.com/

    The name of the architect may contain commas.


    So the pattern match needs to do this:
    Find "Architect: "
    then find ", http://" or "\n" or end of field after that
    take the text in between and put it in the architect field.

    Can this be done?

  2. #2
    Join Date
    Jun 2003
    Posts
    21

    Re: Pattern matching?

    Originally posted by Dylan Leblanc
    I have some data I want to pull out of one field and put into another. The tricky part is that the field the data is in is a text field, and the data could be anywhere in there. So I need to do some sort of pattern matching to find it.

    Here is an example of the query I want to run, but I don't know what to put for the question mark.

    UPDATE Building SET architect = ? WHERE description LIKE '%Architect: %';


    In the description field, architects are in this format:

    Architect: name of architect
    or
    Architect: name of architect, http://example.com/

    The name of the architect may contain commas.


    So the pattern match needs to do this:
    Find "Architect: "
    then find ", http://" or "\n" or end of field after that
    take the text in between and put it in the architect field.

    Can this be done?
    Ofcourse this can be done, but not in a single SQL statement...write a simple ASP script or a litte app to do this. Stored Procedure would be nice...if MySQL had them :-)

  3. #3
    Join Date
    May 2002
    Location
    Vancouver Canada
    Posts
    26
    I figured as much. I will do it in PHP

Posting Permissions

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