Searching products in MySQL

Discussion in 'MySQL' started by adfave, Jul 20, 2010.

  1. #1
    I have following data in products table.

    1. Crib / Toddler - Pale Pink Woven
    2. Bassinet - Pale Pink Woven
    3. Crib / Toddler - Baby Cows

    I am using this query to search.
    SELECT * FROM products WHERE MATCH (pname) AGAINST ('pink crib' IN BOOLEAN MODE)

    Returned rows are 1 and 2 but I want to get first row only if "pink crib" is keyword to search and only second row when keyword is "bassinet pink".

    How's that possible?
     
    adfave, Jul 20, 2010 IP
  2. upl8t

    upl8t Peon

    Messages:
    80
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check the reference at http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html

    It looks like an AND search must be done as +keyword + keyword. The way you have it brings back a result if either of the keywords match.

    SELECT * FROM products WHERE MATCH (pname) AGAINST ('+pink +crib' IN BOOLEAN MODE) should work but I haven't tested it.
     
    upl8t, Jul 22, 2010 IP