0

INNER JOIN, Products and Categories

I have the following Practice: You are working at a supermarket and you need to arrange products by categories. You are given the following tables: Each product has a category. Write a query to output all products with their categories (productname-price-categoryname) in one table. I have tried the folllowing: Select products.ID, categories.ID From products INNER JOIN categories ON products.ID = categories.ID; Select products.productname,products.price,categories.categoryname From products INNER JOIN categories ON products = categories; SELECT Products.categoryid, Categories.categoryname FROM Products INNER JOIN Categories ON Categories.categoryid=Categories.categoryname; SELECT Products.categoryid, Categories.categoryname FROM Products INNER JOIN Categories ON Categories.categoryid=Products.categoryname; SELECT Products.categoryname, Categories.categoryname, FROM Products INNER JOIN Categories ON Products.categoryid=Products.categoryname; No luck. Any suggestions?

15th Sep 2021, 8:12 PM
Jeffrey Tate
10 Respostas
+ 6
select products.productname, products.price,categories.categoryname from products,categories where products.categoryid=categories.id; or SELECT products.productname, products.price, categories.categoryname FROM products INNER JOIN categories ON products.categoryid=categories.id; this will work
4th Jan 2022, 6:07 PM
JAMESHA IBRAHIM K
JAMESHA IBRAHIM K - avatar
+ 1
The correct answer is: SELECT products.productname, products.price, categories.categoryname FROM products INNER JOIN categories ON products.categoryid=categories.id;
30th Sep 2021, 12:10 PM
Shweta Jain
+ 1
Both work: select productname,price,categoryname from products inner join categories on products.categoryid = categories.id; -------OR------ this one work too: select productname, price, categoryname from products as p,categories as c where p.categoryid=c.id;
16th Dec 2021, 11:30 PM
Moussa Diallo
Moussa Diallo - avatar
0
This is what I am currently seeing. Input No Input Your Output productname,price,categoryname Expected Output productname,price,categoryname Apple,800,Fruit Potato,400,Vegetable Orange,900,Fruit Tomato,450,Vegetable OrangeJuice,250,Juice TomatoJuice,350,Juice
15th Sep 2021, 9:19 PM
Jeffrey Tate
0
SELECT products.productname, products.price, categories.categoryname FROM products INNER JOIN categories ON products.categoryid=categories.id;
19th Jan 2022, 9:57 AM
OLEH MOROZ
OLEH MOROZ - avatar
0
select productname,price,categoryname from products inner join categories on products.categoryid = categories.id; this one is working
26th Jul 2022, 12:55 PM
Ash Ketchum
0
SELECT products.productname,products.price,categories.categoryname FROM products INNER JOIN categories ON products.categoryid = categories.id
6th Nov 2022, 1:18 PM
Nagasiva Vakadani
Nagasiva Vakadani - avatar
0
SELECT products.productname, products.price, categories.categoryname FROM products INNER JOIN categories ON products.categoryid=categories.id
5th Feb 2023, 1:35 PM
Daniel
0
SELECT products.productname,products.price, categories.categoryname FROM products INNER JOIN categories on products.categoryid = categories.id This will work
8th Feb 2023, 12:17 PM
Meghana
Meghana - avatar
0
You are working with the tables Products and Orders. Each product has an id, while the Orders table has a referencing product_id. Drag & drop to select the name from the products table and the corresponding price from the orders table.
20th Oct 2024, 5:59 PM
Fais Mohammed Safee
Fais Mohammed Safee - avatar