5

我正在写一个这样的sql

SELECT uid
  FROM search
 WHERE MATCH(product) AGAINST('football basketball')
   AND status=1
 ORDER BY MATCH(product) AGAINST('football basketball') DESC

我在mysql中运行它没问题,但我不确定它是否有效。我想知道这个“ MATCH(product) AGAINST('football Basketball') ”是否跑了两次?

4

2 回答 2

0

这可能无需担心:

SELECT uid, MATCH(product) AGAINST('football basketball') as imatch
  FROM search
 WHERE imatch 
  AND status=1
 ORDER BY imatch DESC
于 2012-10-24T11:09:09.760 回答
0

如果您不想同时选择匹配项,则需要将别名放在 where 子句中。但是别名只运行一次并将结果存储在“变量”中

SELECT uid
FROM search
WHERE MATCH(product) AGAINST('football basketball') as imatch
AND status = 1
ORDER BY imatch DESC 
于 2014-03-05T18:28:31.417 回答