Table:
cat_name / topic
cat1 topic1
cat3 topic1
cat6 topic2
cat4 topic3
cat3 topic3
cat3 topic4
SELECT * from all_cat
WHERE cat_name = "cat4" OR ...
The result should be:
cat4 topic3
cat3 topic4
How to select (in MySQL) all the topic’us form category 4, and even those that belong only to category 3 (example: as topic4, tipoc3 not because he is also belong and category 4).
I find all the topics from the 4 groups, but the topic is a unit with 3 groups meet do not know
Disclaimer: I have no database to test on, these are just suggestions to get you started.
These examples assume you have some kind of constraint to prevent duplicate rows.
If you just want the topics that occur once in the list (that is, belong to one category only), you could use having:
select topic, count(*) from all_cats group by topic having count(*) = 1If you want all of the topics, but only want them returned once:
select distinct topic from all_catsIf you specifically want all of the topics from cat4 and cat3 where the topic does not exist in cat4:
If you want a list of topics that belong only to cat4 or only to cat3 (exclusive or) you can use a variant of the having statement I posted earlier:
select topic, count(*) from all_cats where cat_name in ('cat3', 'cat4') group by topic having count(*) = 1