-1

my sql query is :

SELECT
    wp_news_contents.*,
    (SUM(IF(sumset,1,0))/(COUNT(wp_news_tags.tag_id) +2)) AS jaccard,
    (
        SELECT GROUP_CONCAT('wp_news_tags.tag_id=',tag_id SEPARATOR ' || ')
        FROM wp_news_tags
        WHERE content_id = 1
    ) AS sumset
FROM wp_news_contents, wp_news_tags
WHERE wp_news_contents.id = wp_news_tags.content_id
AND wp_news_tags.content_id != '1'
AND jaccard > 0.5
GROUP BY wp_news_contents.id
ORDER BY id DESC
LIMIT 0, 5

but query not working and show error :

jaccard columns not defined

what is wrong & how to solve it ?

GYaN
  • 2,327
  • 4
  • 19
  • 39
  • Possible duplicate of [WHERE vs HAVING](https://stackoverflow.com/questions/2905292/where-vs-having) – P.Salmon Apr 17 '18 at 07:57

1 Answers1

0

you can't add any other fields after the 'select ', you can use the '' without any other fields or just list all the fields you want without ''. try replace the '' with all the specific fields you want.

phinche
  • 93
  • 5