-2
Hello. I would like a SELECT INNER JOIN result to show the record name instead of the record ID. I have researched several topics dealing with the subject here, but I cannot solve this problem. I have 4 tables where in case 3 of them are related to a table.
Below follows a description of the 4 tables mentioned:
tbl_tipos
----------------
tipo_id
tipo
tbl_categorias
-----------------
categoria_id
categoria
tbl_subcategorias
------------------
subcategoria_id
subcategoria
categoria_fk
tbl_produtos
------------------------
produto_id
tipo_fk
categoria_fk
subcategoria_fk
nome
descricao
What happens is that when you make the SELECT INNER JOIN as below, the tbl_products-related registry name does not appear, but the ID does:
SELECT tbl_produtos.*, tbl_tipos.tipo, tbl_categorias.categoria, tbl_subcategorias.subcategoria
FROM tbl_produtos
INNER JOIN tbl_tipos ON tbl_produtos.tipo_fk = tbl_tipos.tipo_id
INNER JOIN tbl_categorias ON tbl_produtos.categoria_fk = tbl_categorias.categoria_id
INNER JOIN tbl_subcategorias ON tbl_produtos.subcategoria_fk = tbl_subcategorias.subcategoria_id;
Upshot:
How do I show the name instead of the ID? Thank you.
I believe that what is being displayed are the categoria_fk and subcategoria_fk fields of tbl_products, since you have placed tbl_products. * in your SELECT.
– anonimo