Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2013
    Posts
    6

    Unanswered: find and replace

    Hi,

    i have the string from the description like below. I want to find the first " and replace with empty.

    "S40 12"" 316,316,17-4,RTFE/SI
    final result will be:
    S40 12"" 316,316,17-4,RTFE/SI

    thanks

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    In MySQL (where you posted the question) or in Microsoft SQL (which you used for your previous question)? The solutions are quite different due to how the SQL dialects handle strings.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    In MySQL this would be

    Code:
    mysql> select name, concat(substring_index(name, '"', 1), substring(name, instr(name, '"')+1)) from teststring;
    +--------------------------------+----------------------------------------------------------------------------+
    | name                           | concat(substring_index(name, '"', 1), substring(name, instr(name, '"')+1)) |
    +--------------------------------+----------------------------------------------------------------------------+
    | "S40 12"" 316,316,17-4,RTFE/SI | S40 12"" 316,316,17-4,RTFE/SI                                              | 
    | S40 "12"" 316,316,17-4,RTFE/SI | S40 12"" 316,316,17-4,RTFE/SI                                              | 
    | S40 12"" 316",316,17-4,RTFE/SI | S40 12" 316",316,17-4,RTFE/SI                                              | 
    +--------------------------------+----------------------------------------------------------------------------+
    3 rows in set (0.00 sec)
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

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