Click to See Complete Forum and Search --> : mysql ‘Unknown column’ error


deadfish
01-15-2010, 03:56 AM
Can any one help, I can't for the life of me figure out 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''

NogDog
01-15-2010, 02:52 PM
Since both the group_concat() and match() are essentially happening at the same time, the "tags" alias created by the group_concat() doesn't yet exist as far as the match() is concerned. Depending on what you want to happen, you'll either need to reference the actual w.tag_word column name in the match(), or else separate this into two queries (maybe the grouping being done in a sub-query?).