Link to home
Start Free TrialLog in
Avatar of Cesar Aracena
Cesar AracenaFlag for Argentina

asked on

Select from 3 tables with a single query in MySQL with PHP

Hello,

I have to select all items from a MySQL table using PHP but from categories that the user is allowed to see. I've tried having all the categories in an array and then imploding them while using the IN statement in the SQL query (tried like 10 different methods with INT and STRING arrays) with no luck. The problem is that I'm getting dizzy while trying to figure out a somewhat complex (at least for me) JOIN statement.

I have the following tables:

User generated image
As you can see, it should be pretty easy except that a user may have more than one category assigned to it. How can I show Helen in this example all the products and/or categories she can see in a single query?

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cesar Aracena

ASKER

Thanks Paul!

I'm not on my working computer and that's why I don't have all the needs in hand but this sure will work! I'll try it tomorrow and come back with the result.

Thanks again!
Thanks Paul! It works perfectly. And it was easier than I thought ;)