SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Sorting in Fulltext search

    MySQL returns an error when I add

    AS rel WHERE rel > 0 ORDER BY rel DESC

    to this query

    "SELECT msgID, header, location, postingDate FROM posting_tb WHERE MATCH (emailBody) AGAINST ('$query'"

    I would like to sort the result from the query by relevancy.

    Any ideas? Thanks

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is the error something such as "Unknown column 'rel' in WHERE clause?" that's because rel isn't a column. if you wanted to use rel's value in a WHERE-like clause, it would be HAVING:

    AS rel HAVING rel > 0 ORDER BY rel DESC

    however, a WHERE/HAVING shouldn't be needed. just use ORDER BY rel DESC and you should get the desired results.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i apologize! after i posted this last night, i realized that i told you wrong. i forgot how FULLTEXT search works. i think this is the correct query:

    SELECT msgID, header, location, postingDate, MATCH (emailBody) AGAINST ('$query') AS rel FROM posting_tb WHERE MATCH (emailBody) AGAINST ('$query') ORDER BY rel DESC


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
  •