user13056466
user13056466

Reputation:

basic Replacement of row in select

I am pretty new with MySQL and my question is

How could I make it so in the selection I make the "Bike_ID" instead show the "bike_name" but match with the orders table?

It shows:

# Orders_ID, Bike_ID, Serial_Number
    '1',       '4',     '204358'

What I want the selection to show:

# Orders_ID, Bike_name, Serial_Number
    '1',       'Honda Monkey',     '204358'

I added two screenshots from the shell of the tables.

enter image description here

enter image description here

Upvotes: 1

Views: 27

Answers (1)

GMB
GMB

Reputation: 222502

You seem to be looking for a simple join:

select o.orders_id, m.bike_name, o.serial_number
from orders o
inner join motorbike m on m.bike_id = o.bike_id
where o.customer_id = 1

Upvotes: 2

Related Questions