I’ve hit a wall with my mySQL knowledge.
To explain it more clearly here are my tables (a pretty standard setup for tags):
keywords
---
keyword_id (ai)
keyword
–
topics_keywords
---
t_k_id (ai)
topics_id
keyword_id
–
topics
---
topics_id
etc
Now, lets say that keywords table has the following entries:
keyword_id || keyword
1 || baseball
2 || sports
And topics_keywords has the following entries:
t_k_id || topics_id || keyword_id
1 || 1 || 1
2 || 1 || 2
3 || 2 || 1
So maybe you can see what im trying to do.
If someone inputs ‘baseball’ I want to get a COUNT for how many topics that share a related keyword. In the above example, baseball and sports are both shared keywords for topics_id: 1.
So if someone inputs baseball how would I get the count() that displays there is 1 other topic out there, named sports that shares a topic with baseball?
If I understand you correctly you might want to look into running something like this:
SQL Fiddle: http://sqlfiddle.com/#!2/9e6be/6
That is, you’re selecting the count of topics_keywords that do not have the keyword you’re looking for but do have the topics_id of the keyword you’re looking for.