Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009

    Unanswered: Parsing a string

    I need to update a record in table users where the record number is within a variable

    the variable is called “ invoice” it’s value is G-123-456

    I need to filter on just the 456 part of the variable.

    UPDATE users
    SET active=0
    WHERE user_usr LIKE ‘ ‘’-’’-invoice

    Not sure where to start on this.


  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    look at the MySQL string functions

    on the face of it right looks promising
    it should be trivial if there are always 3 characters to match. if not then you are going to have to dabble with the likes of instr to find where to start comparing
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2007
    Richmond, VA
    Provided Answers: 5
    Or set up a column that just holds that piece of the invoice you are after. You could even set up a trigger to populate it at insert time.

  4. #4
    Join Date
    Jan 2009
    This is a the variable are from PayPal IPN which has ver limited number of fields to work with. I was hoping to put all the information I needed into a single field and parse it when I receive the notification. Would it help if I formatted it: G123IM456 then look for letters followed by numbers?

  5. #5
    Join Date
    Mar 2004
    look up the use of SUBSTRING_INDEX and leave the - in there to search on.

  6. #6
    Join Date
    Dec 2009

    better idea

    why not use REGEXP and regular expression
    since the expression is simple, it should work fast.

    Check: MySQL :: MySQL 5.1 Reference Manual :: 11.5.2 Regular Expressions

Posting Permissions

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