macmilm macmilm - 6 months ago 42
SQL Question

Many to Many SQL Query Join

Am attempting to query the following. Basically clients can be in a number of categories. I have a list of check boxes of the categories and want to only display the clients of the selected categories. I have been trying to use an inner join but my SQL is still in its infancy and I am clearly getting it wrong . Any advice greatly appreciated . Thanks for reading.

my tables layout :

enter image description here

select * from clients join clientscategories on clients.idclient=clientscategories.idclient join categories on clientscategories.idcat=categories.idcat WHERE clientscategories.idcat IN (v1,v2,......)

I think you can try this, Please provide the values that you are selecting from check boxes to v1,v2...