SELECT * FROM table, replace FK with your name

I have 2 tables, the product has a primary key and name, the price has pk, a fk(pk of product)and the price. Now I have to select * from price, but you need to show the product name instead of fk. How can i do this?

+3
source share
2 answers
SELECT pd.name, pc.price
    FROM product AS pd
        INNER JOIN price AS pc
            ON pd.id = pc.productid
+3
source

you can do it like this:

Select p.*, pr.Name from price as p
join product as pr on p.productid = pr.Id
+2
source

Source: https://habr.com/ru/post/1778414/


All Articles