Query Help Needed

Discussion in 'MySQL' started by deriklogov, Sep 10, 2007.

  1. #1
    Hi everyone,
    I have a table
    -------------------------------------
    | name| desc | tag |
    -------------------------------------
    |text1 | Laptop | Laptop |
    --------------------------------------
    |text2 |Laptop Battery|Laptop Battery|


    I have this query:
    SELECT *, MATCH (`tag`,`desc`) AGAINST ('laptop' IN BOOLEAN MODE) as score FROM test WHERE MATCH (`tag`,`desc`) AGAINST ('laptop' IN BOOLEAN MODE) ORDER BY score

    I want to make an order of results , but first results should come with word "laptop" in tag field , so I dont want to see in first position Laptop Battery on search results. but if the search term will be "laptop battery| than order should start with Laptop battery.
     
    deriklogov, Sep 10, 2007 IP
  2. hamidof

    hamidof Peon

    Messages:
    619
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You are doing Full-Text search and it's up to MySQL to decide which rows match the best but if you want to do that, use a select statement before this query and then append the result to your search result:
    SELECT * FROM test WHERE tag = 'laptop';
     
    hamidof, Sep 13, 2007 IP