tags:

views:

50

answers:

1

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.

+2  A: 

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".

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