Martin
Martin

Reputation: 41

How can I show values from two tables with one SELECT command in SQL?

I have two tables. First table has food items with prices on it. The other table has orders of foods on it. Both tables have the same named food items. What I would like to do is, have the price show as an extra column behind the particular food item in one table.

I don't even know how to search for this, I tried and failed miserably. So now I am turning to people who are most likely better at SQL.

Hope someone understands my problem and is able to help me.

Upvotes: 1

Views: 116

Answers (1)

Alex
Alex

Reputation: 371

Use a join:

select orders.*, prices.price
from orders
join prices on prices.foodName = orders.foodName

Upvotes: 6

Related Questions