SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Using LIKE %

  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using LIKE %

    Hi all,

    How do I know where to place the % on LIKE in a query??

    How is LIKE %$name% different to LIKE %$name or LIKE $name% ?

    Thanks.

    Kevin.

  2. #2
    SitePoint Evangelist Will Kelly's Avatar
    Join Date
    May 2005
    Location
    London
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    name LIKE '%$name%'

    if you want to match the beginning of the field remove the first %, the end remove the last.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LIKE %$name% finds strings containing $name anywhere in a word
    LIKE %$name finds strings ending with $name
    LIKE $name% finds strings starting with $name

  4. #4
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys!

    Problem is I have a keyword in db table called pricing

    I want to enter price into search field.

    However using LIKE '".$keyword."%' doesn't return pricing.

    Why is this?

    If I enter prici it returns pricing.

  5. #5
    SitePoint Evangelist Will Kelly's Avatar
    Join Date
    May 2005
    Location
    London
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you might get better support in the MySQL forum...


Bookmarks

Posting Permissions

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