good morning.
I am registering the sale of a product with its unique ID and price, I am wanting to make a report that tells me what category that product belongs to that is in another table.
How can I perform the query in several tables?
good morning.
I am registering the sale of a product with its unique ID and price, I am wanting to make a report that tells me what category that product belongs to that is in another table.
How can I perform the query in several tables?
You should use a INNER JOIN
, its functionality is to "join" the different tables with a "field".
For example:
SELECT producto.id, producto.nombre, producto.precio, categoria.nombre
FROM producto
INNER JOIN categoria
ON producto.categoria_id = categoria.id
In the event that the producto
table contains the id
of the category it belongs to (which is normal)