开发者

Combining SQL Query Results Into One Table

开发者 https://www.devze.com 2023-03-02 01:18 出处:网络
I\'m trying to combine queries so the results are in one table. SELECT sku.idsku, amaterial.material FROM sku

I'm trying to combine queries so the results are in one table.

SELECT sku.idsku, amaterial.material
FROM sku
INNER JOIN amaterial ON sku.idsku = amaterial.sku_idsku
LIMIT 0 , 30

Produces:

idsku material

13 Steel

SELECT sku.idsku, amcolor.color
FROM sku
INNER JOIN amcolor ON sku.idsku = amcolor.sku_id开发者_Go百科sku

Produces

idsku color

13 red

17 purple

SELECT sku.idsku, atype.type
FROM sku
INNER JOIN atype ON sku.idsku = atype.sku_idsku

Produces

idsku type

13 labret

17 barbell

What I want to create is a table as follows:

idsku material color type

13 steel red labret

17 ---- purple barbell

Thanks in advance for your help.


what if you put all your queries into one?

 SELECT sku.idsku, amaterial.material, amcolor.color, atype.type
 FROM sku sku
 INNER JOIN amaterial ON sku.idsku = amaterial.sku_idsku
 INNER JOIN amcolor ON sku.idsku = amcolor.sku_idsku
 INNER JOIN atype ON sku.idsku = atype.sku_idsku
 LIMIT 0 , 30
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号