Replace in query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paradigm

    #1

    Replace in query

    Is there the equivalent of the Access REPLACE that I can use in a query.
    eg
    "SELECT * FROM MYTABLE WHERE REPLACE(MYFIELD ,"'",".") = """ &
    REPLACE(MYTEXT, "'",".")"

    I need to do this because I want to check if 2 text strings are equal but
    the strings can contain quotation marks so I thought that if I could replace
    the quotations with another character and then check for equality would be
    the best way.

    Alex


  • Aggro

    #2
    Re: Replace in query

    Paradigm wrote:[color=blue]
    > Is there the equivalent of the Access REPLACE that I can use in a query.[/color]

    REPLACE(str,fro m_str,to_str)

    Returns the string str with all occurrences of the string from_str
    replaced by the string to_str.

    mysql> SELECT REPLACE('www.my sql.com', 'w', 'Ww');
    -> 'WwWwWw.mysql.c om'


    http://dev.mysql.com/doc/mysql/en/String_functions.html

    Comment

    Working...