MySQL query in several tables

-1

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?

    
asked by Gustavo Lopez 22.10.2018 в 15:13
source

1 answer

0

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)

    
answered by 22.10.2018 / 15:22
source