lundi 26 juin 2017

MySQL / Laravel / Eloquent: Select rows that exist in 2 tables

I have a users table, and 2 pivot tables (user_locations, user_roles) that allows users to associate with multiple "locations" and "roles". What's the best way to select users that belong to, say, New York (a location) and Manager (a role)?

Columns in each table:

Table users => id, name

Table user_locations => user_id, location_id

Table user_roles => user_id, role_id

So, for example, I'd like to get a list of users that are associated with location_id 100, and role_id 200

I hope I'm explaining my goal clearly. Thank you in advance!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uadhJK
via IFTTT

Aucun commentaire:

Enregistrer un commentaire