Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007
    Posts
    2

    Unanswered: Repeat computation in WHERE and ORDER BY

    Hi. I have question if MySQL computes the same intructions which are in WHERE, HAVING and ORDER BY clause two times or only one?

    Example:
    SELECT id FROM users
    HAVING MATCH(tytul,opis,tags) AGAINST('doda') >0
    ORDER BY MATCH(tytul,opis,tags) AGAINST('doda') DESC)

    Will MySQL compute one or two times MATCH(tytul,opis,tags) AGAINST('doda') ?

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I'm sure your statement should probably be :
    Code:
    SELECT id FROM users
    HAVING MATCH(tytul,opis,tags) AGAINST('doda') >0
    ORDER BY tytul,opis,tags DESC
    However, having not tested this resultset I cannot say for sure this will give you the result you desire.
    You might want to run EXPLAIN on this query to see what it does.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by pajakleon
    Will MySQL compute one or two times MATCH(tytul,opis,tags) AGAINST('doda') ?
    i'm pretty sure only once

    note you do not need an ORDER BY clause if you want results based on relevance -- that's the default
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •