just like the caption, how do i fetch information from foreign key instead of id?
Here are the first table:
and here are the second table:
i want to display product_name and unit_price instead of id, how to do it?
CodePudding user response:
You need to use join Your query should look something like this:
SELECT ft.id, pr.product_name, pr.unit_price from firsttable as ft join product as pr on ft.product_id = pr.product_id;
Where firsttable
is the table of the first screenshot and product
is the table from the second screenshot.
I don't know what you need from the first table so I just took a column id
, however I do not know if you have this column. Here you just put whatever you need from the first table.