I'm new to databases. So, I got two tables product and supplier, and I need to make a query that prints the sold out products alongside some supplier information.
product table:
| Product_ID | Product_Name | Quantity | Supplier_ID |
|---|---|---|---|
| 1 | water | 0 | 11 |
| 2 | Milk | 26 | 12 |
| 3 | eggs | 8 | 12 |
| 4 | 5L water | 19 | 11 |
| 5 | water gallon | 0 | 11 |
supplier table:
| Supplier_ID | Supplier_Name | Supplier_Phone |
|---|---|---|
| 11 | Pure life | 55555555 |
| 22 | Dairy | 77777777 |
| 33 | Nivea | 66666666 |
My work so far:
SELECT product.Product_ID, 'product.Product_Name', product.Quantity,
'supplier.Supplier_Name', supplier.Supplier_Phone
FROM product, supplier
INNER JOIN supplier S ON supplier.Supplier_ID = product.Supplier_ID
WHERE (Quantity = 0)
GROUP BY 'product.Product_Name';
The output:
Error Code: 1054. Unknown column 'product.Supplier_ID' in 'on clause'
the desired output:
| Product_Name | Quantity | Supplier_Name | Supplier_Phone |
|---|---|---|---|
| water | 0 | Pure life | 55555555 |
| water gallon | 0 | Pure life | 55555555 |