I have in my database a table projects
.
In this table there is a row categories
where are all the categories_id where a a project is in. For example a project is in category 1 and 2, so the row value is 1,2
.
What I want is to count all the projects in a category. So I try this:
select * from `projects` WHERE '{$id_cat}' IN (`categories`)
but it does not count the projects that have more than one category. I dont want to use LIKE
select * from `projects` WHERE `categories` LIKE '%{$id_cat}%'
because for example if I have a project that is in category 11 and I try to find all project in category 1 this query will return this value too.