If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Repeat computation in WHERE and ORDER BY

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-12-07, 03:51
pajakleon pajakleon is offline
Registered User
 
Join Date: Aug 2007
Posts: 2
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') ?
Reply With Quote
  #2 (permalink)  
Old 09-12-07, 05:00
aschk aschk is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 09-12-07, 07:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On