Problem in fetching data using LIKE keyword

Discussion in 'MySQL' started by shaibibutt, Jul 25, 2009.

  1. #1
    Hello all
    I am trying to fetch data from my MYSQL database, but i am facing problem. My query is
    Select title, ref from algorithm where title like '_%test' order by DateTime DESC;

    Suppose I want to search a line which contains the word TEST and data in my database is

    This is test
    He is trying to test the application
    TEST of mathematics

    Now the problem is that the query only returns that row which has TEST as its last word, i-e this query will return the first row only coz the word TEST is at the end of the line. If i try to search the word TRYING, the query doesn't return any result.. plz help me out.
     
    shaibibutt, Jul 25, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Try: where title like '_%test%'
     
    jestep, Jul 25, 2009 IP
  3. DoDo Me

    DoDo Me Peon

    Messages:
    2,257
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try: where title like '%test%'

    why need a _
     
    DoDo Me, Jul 25, 2009 IP
  4. shaibibutt

    shaibibutt Member

    Messages:
    606
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #4
    Thank you both of u :)
    Let me try it :)
     
    shaibibutt, Jul 26, 2009 IP
  5. shaibibutt

    shaibibutt Member

    Messages:
    606
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #5
    Thank you, I tried without _ , and it worked fine for me. :)
     
    shaibibutt, Jul 26, 2009 IP