basic Replacement of row in select

user13056466 :

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

GMB :

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=298207&siteId=1