like statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jean-Baptiste

    #1

    like statement

    Hi,

    I am trying to do something I am not sure we can do...
    In fact, I would like to test that a field is included in a string.

    An example could be helpfull :

    Instead of doing this :

    SELECT ... FROM myTable WHERE field LIKE '%string%'

    I would like to do something like this :

    SELECT ... FROM myTable WHERE 'string' LIKE "%"+field+" %"

    I already tried whith concatenation but it doesn't work. If someone
    knows a way to do it, I would really appreciate !

    Thanks,

    Jb
  • Aggro

    #2
    Re: like statement

    Jean-Baptiste wrote:
    [color=blue]
    > SELECT ... FROM myTable WHERE 'string' LIKE "%"+field+" %"[/color]

    select * from myTable where 'string' like concat('%',fiel d,'%');

    Comment

    • Raqueeb Hassan

      #3
      Re: like statement

      > SELECT ... FROM myTable WHERE 'string' LIKE "%"+field+" %"

      SELECT ... FROM myTable WHERE 'string' LIKE "%%field%%" ;

      What I understand that you want to match even that literal percent
      character, then escape it by doubling it.

      hth

      --
      raqueeb hassan
      congo (drc)

      Comment

      Working...