[RESOLVED] MySQLi join based on crosstable
I've been searching and trying this for a while but I can't seem to find out how to do this. I have the following 3 tables as an example:
I'm looking for a single MySQLi query to get both the ownername and petname of one specific pet.
select owners.name as owner_name, pets.name as pet_name
inner join petsOwned on petsOwned.petId = pets.id
inner join owners on petsOwned.ownerId = owners.id
where pets.id = ?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Thank you! That works perfectly
Originally Posted by NogDog
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)