经销商表
name id
usf south 1
usf north 2
usf east 3
usf west 4
ogi table
distributor itemname
1 cheese
1 apples
3 oranges
2 pineapples
我目前在页面上为每个项目名称显示的“ogi表”列中的“distributor”列中找到了该编号。但是,我想将此编号更改为正确的经销商名称,可在“经销商表”中找到。我怎么能这样做?
感谢您的帮助。
答案 0 :(得分:1)
SELECT a.*, b.*
FROM distributors a
INNER JOIN ogi b
ON a.id = b.distributor
要充分了解联接知识,请访问以下链接:
答案 1 :(得分:1)
如果您对仅替换查询而不替换任何下划线编程感兴趣,这可能是一个可行的解决方案:
SELECT
ogi.itemname,
distributors.name AS distributor
FROM
ogi
INNER JOIN
distributors
ON
ogi.distributor = distributors.id
答案 2 :(得分:0)
本教程将向您展示如何存档。