UPDATED:
Product Table Structure:
productId
pnumber
pdescrip
Companyproducts Table Structure:
companyId
product
serialnumber
said
customerproducts从产品中保存productId 我需要拉出所有的cusomterproducts列 以及如何从产品表中提取product.pnumber和product.pdescrip,其中customerproducts.product = products.productId
答案 0 :(得分:1)
您的表格结构对我来说并不清楚,但根据您提供的方案,您可以根据product id
加入两个具有相同ID的表格
SELECT
a.customerid,
a.customername,
a.serialnumber,
a.SAID,
b.productID,
b.productdescription
FROM
customerproducts AS a
INNER JOIN products AS b ON a.productId = b.productID
或者,如果您不是家中使用tablename As a
和tablename2 As b
等短名称的家庭,您可以直接将以下代码与实际的表名一起使用,但这对您来说很难理解长查询
SELECT
customerproducts.cutomerid,
customerproducts.customername,
customerproducts.serialnumber,
customerproducts.SAID,
products.productID,
products.productdescription
FROM
customerproducts
INNER JOIN products ON customerproducts.productId = products.productID