我正在写一个像这样的SQL
SELECT uid
FROM search
WHERE MATCH(product) AGAINST('football basketball')
AND status=1
ORDER BY MATCH(product) AGAINST('football basketball') DESC
我在mysql中运行正常,但我不确定它是否有效。我想知道这个“ MATCH(产品)反对('足球篮球')”是否会跑两次?
答案 0 :(得分:0)
这可能无需担心:
SELECT uid, MATCH(product) AGAINST('football basketball') as imatch
FROM search
WHERE imatch
AND status=1
ORDER BY imatch DESC
答案 1 :(得分:0)
如果您不想同时选择匹配项,则需要将别名放在where子句中。但是别名只运行一次并将结果存储在“变量”
中SELECT uid
FROM search
WHERE MATCH(product) AGAINST('football basketball') as imatch
AND status = 1
ORDER BY imatch DESC