1

如果设置为,则它使用MySQL Extensions to GROUP BY并且无法执行。sql_modeONLY_FULL_GROUP_BY

-- SET sql_mode = ""; -- reset sql_mode and execute statement
SELECT
    `courses`.`id` AS `id`,
    `courses`.`title` AS `title`,
    `courses`.`description` AS `description`,
    MATCH (coursedata.title) AGAINST ('Salsa') * 5 + MATCH (coursedata.description) AGAINST ('Salsa') * 2 AS `relevance`
FROM `courses`
INNER JOIN `coursedata` ON `courses`.`id` = `coursedata`.`id`
GROUP BY `courses`.`id`
HAVING `relevance` >= '3'

用标准的SQL能达到同样的效果吗?

4

1 回答 1

0

似乎工作...

SELECT * FROM (
    SELECT
        DISTINCT `courses`.`id` AS `id`,
        `courses`.`title` AS `title`,
        `courses`.`description` AS `description`,
        MATCH (coursedata.title) AGAINST ('Salsa') * 5 + MATCH (coursedata.description) AGAINST ('Salsa') * 2 AS `relevance`
    FROM `courses`
    INNER JOIN `coursedata` ON `courses`.`id` = `coursedata`.`id`
) AS subselect
WHERE `relevance` >= '3'
于 2013-04-15T22:59:53.377 回答