I know that the following will return the highest price in the 'price' column:
How can I also get it to show the corresponding item with the max price?Code:SELECT MAX(price) FROM items_ordered;
I have played around with it but can't figure it out.
| SitePoint Sponsor |

I know that the following will return the highest price in the 'price' column:
How can I also get it to show the corresponding item with the max price?Code:SELECT MAX(price) FROM items_ordered;
I have played around with it but can't figure it out.
Assuming that your items table is called "items" and that the item name field is called "name"
Code SQL: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
Community Team Advisor
Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


Community Team Advisor
Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

Bookmarks