SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    SQL LIKE Function Help

    Hello

    in a mysql table there is a piece of data under POSITIONS column 'TECHNICAL ASSISTANT (ENVIRONMENTAL)'

    i have a piece of string 'MANAGER ENVIRONMENTAL ENGINEERING'.
    i want a query when issued, this string should match the above.

    currently i am using the below query.

    Code:
    SELECT * FROM TABLENAME
    WHERE POSITIONS LIKE '%MANAGER ENVIRONMENTAL ENGINEERING%'
    OR   POSITIONS LIKE '%MANAGER ENVIRONMENTAL ENGINEERING'
    OR POSITIONS LIKE 'MANAGER ENVIRONMENTAL ENGINEERING%'
    But it's not matching. Please help

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,262
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    you have to break down the search string into individual words (using your application language, php or whatever)
    Code:
    WHERE positions LIKE '%manager%'
       OR positions LIKE '%environmental%'
       OR positions LIKE '%engineering%'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    you have to break down the search string into individual words (using your application language, php or whatever)
    Code:
    WHERE positions LIKE '%manager%'
       OR positions LIKE '%environmental%'
       OR positions LIKE '%engineering%'


    Thank you r937!
    btw, my language is php, ill explode the words and feed to the query then.


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
  •