I'm doing a system in PHP, but I'm stopped because I can not find the solution to a challenge.
I have 2 tables, one call objetos
and another call gavetas
. I have several names of drawers registered in the gavetas
table and I need to know which ones have objects inside them.
I'm trying to make a select
where regardless of whether or not to have an object inside the drawer, bring all the records of the gavetas
table and the ones that have object, display the name of the object on the side. And when you have (Pen) inside the drawer PHP prints the (found) word next to the object name. I've tried INNER JOIN / LEFT JOIN / RIGHT JOIN
, but I'm not getting the desired result.
Tables:
**Gavetas**
id
nome-gaveta
**Objetos**
id
nome-gaveta
nome-objeto
Example
Gaveta 1 / Caneta - Encontrado
Gaveta 2 /
Gaveta 3 /
Gaveta 4 /
Gaveta 5 / Borracha