Skip to content
Advertisement

How to fetch all values of a column based on value of another column in same table?

I got the following structure:

How to fetch all values by taking the $_SESSION['admin']['id'], finding the country_id of that admin and getting all other admin_id and country_id that are the same of the session admin?

So, lets say the currently logged in admin has id = 5 , that means the admin_id: 5 has two country_id: 1 and 62. I want to take all rows that have country_id: 1 and 62.

It should return this:

How can I do this in one sql query?

Advertisement

Answer

You can use a where clause for filtering on the admin_id or the country_id:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement