LIKE % Operator

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

    #1

    LIKE % Operator

    Dear all,

    I want to perform a simple search for a query such as:

    SELECT *
    FROM SOME_TABLE
    WHERE SOME_TABLE.SOME _COLUMN LIKE '%SOME_KEYWORD% '

    The same statement if implemented in a stored procedure would look
    similar like this:
    CREATE PROCEDURE sp_FindKeyword (IN SOME_KEYWORD AS VARCHAAR(55))
    BEGIN
    SELECT *
    FROM SOME_TABLE
    WHERE SOME_TABLE.SOME _COLUMN LIKE '%' + SOME_KEYWORD + '%' ;
    END

    But this does't work ....
    I know I could manipulate the '%' before passing the parameter using
    the interface language such as php, asp, ..etc. but is there a way this
    can be done using MySql 5 itself?

    Best regards

  • Bill Karwin

    #2
    Re: LIKE % Operator

    "coosa" <coosa76@gmail. com> wrote in message
    news:1137188021 .686491.22540@f 14g2000cwb.goog legroups.com...[color=blue]
    > WHERE SOME_TABLE.SOME _COLUMN LIKE '%' + SOME_KEYWORD + '%' ;[/color]

    MySQL uses the CONCAT() function to concatenate string. For example:

    WHERE SOME_TABLE.SOME _COLUMN LIKE CONCAT('%', SOME_KEYWORD, '%')

    String concatenation, strangely, is nonstandard in many RDBMS
    implementations . In the ANSI SQL standard, the string concatenation
    operator is ||, but few RDBMS's seem to do it that way.

    Regards,
    Bill K.


    Comment

    • coosa

      #3
      Re: LIKE % Operator

      Thanks

      Comment

      Working...