I know that the following will return the highest price in the ‘price’ column:
SELECT MAX(price)
FROM items_ordered;
How can I also get it to show the corresponding item with the max price?
I have played around with it but can’t figure it out.
I know that the following will return the highest price in the ‘price’ column:
SELECT MAX(price)
FROM items_ordered;
How can I also get it to show the corresponding item with the max price?
I have played around with it but can’t figure it out.
here’s a quick way:
SELECT item, price
FROM items_ordered
ORDER BY price DESC LIMIT 1
spacephoenix, i think there might have been only one table involved in this question
Assuming that your items table is called “items” and that the item name field is called “name”
SELECT
MAX(orders.price) AS highest_price
, items.name AS item
FROM
items_ordered AS orders
INNER JOIN
items
ON
items.item_id = orders.item_id
I did wonder if it was just one table. Andwise, is it one table or is it two tables?
It is one table. Sorry for not specifying. I never considered using the limit function.
Thanks for your help.