0

What is wrong with this:

SELECT *, 
GROUP_CONCAT(DISTINCT w.tag_word ORDER BY w.tag_word ASC SEPARATOR ' ') AS tags, 
MATCH (title, description, tags) AGAINST ('london') AS score 

FROM article G 
      JOIN tag_index I ON G.article_id = I.tag_target_id 
      JOIN tag_word W ON I.tag_word_id = W.tag_word_id 

WHERE I.tag_type_id = 1 AND MATCH (title, description, tags) AGAINST ('london')
GROUP BY G.article_id

I get the error 'Unknown column 'tags' in 'field list''

UPDATE:

Thank you Parrots for pointing out that I need the HAVING clause. I still can not figure out how to implement it. I can only guess it can not be done in one query and needs to be a subquery.

1 Answer 1

2

Since "tags" a value you're creating using GROUP_CONCAT you need to use the having clause. Whenever you want to apply a condition to stuff after the grouping, use having. It works the same as where just after the grouping.

Where in your code example is trying to be applied to filter the results from article that will eventually be grouped to build things like "tags".

Sign up to request clarification or add additional context in comments.

1 Comment

I still can't seem to get it to cooperate... any ideas how I should implement it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.