Answer the question
In order to leave comments, you need to log in
MySQL. How to combine fields with the same data from different tables in a query?
There is a database computer_company , it has 4 tables (which can be seen in the picture). The task is:
"Find the model numbers and prices of all products (of any type) released by the ASUS manufacturer."
Here's what I got:
SELECT product.model, pc.price, laptop.price, printer.price
FROM product
INNER JOIN pc ON product.model = pc.model
INNER JOIN laptop ON product.model = laptop.model
INNER JOIN printer ON product.model = printer.model
WHERE product.maker LIKE "ASUS";
Answer the question
In order to leave comments, you need to log in
Basically, you've already done everything. Empty set apparently means that the request returned an empty set. If it bothers you that the fields are named the same, then there is the as keyword:
The query returns an empty set, most likely due to INNER JOIN, because when using it, it is required that all three tables simultaneously have data corresponding to each row from the table specified in from, which, apparently, is not the case in your case.
Use OUTTER JOIN aka LEFT JOIN.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question