1
我在將數據從一個表複製到另一個表時存在問題。有很多解決方案,但我的問題是不同的。我有兩個表sku
和shipping_skudetails
。我有數據形式shipping_skudetails
複製到sku
,這個在做這個,將數據表複製到未在列查詢中指定列的表
INSERT INTO shyplite.sku
SELECT SkuDetailsId as id,
sku,
seller_id as sellerID,
itemName as name,
itemLength as length,
itemWidth as width,
itemHeight as height,
itemWeight as weight,
modeType_id as mode
FROM shyplitelivedb.shipping_skudetails;
+----+---------+----------+-------------+--------+-------+--------+--------+------+
| id | sku | sellerID | name | length | width | height | weight | mode |
+----+---------+----------+-------------+--------+-------+--------+--------+------+
| 1 | Sample | 1 | SampleItem | 1 | 1 | 1 | 1 | 1 |
| 2 | Sample | 2 | Sample1 | 1 | 1 | 1 | 1 | 1 |
| 3 | SDGS046 | 1 | Shivaprasad | 1 | 1 | 3 | 1 | 2 |
+----+---------+----------+-------------+--------+-------+--------+--------+------+
shyplite.sku
+--------------+---------+-----------+-------------+------------+------------+------------+-----------+
| SkuDetailsId | sku | seller_id | itemName | itemLength | itemWeight | itemHeight | itemWidth |
+--------------+---------+-----------+-------------+------------+------------+------------+-----------+
| 1 | Sample | 1 | SampleItem | 1 | 1.000 | 1 | 1 |
| 2 | Sample | 2 | Sample1 | 1 | 1.000 | 1 | 1 |
| 3 | SDGS046 | 1 | Shivaprasad | 1 | 3.000 | 1 | 1 |
+--------------+---------+-----------+-------------+------------+------------+------------+-----------+
shyplitelivedb.shipping_skudetails
現在的問題是值複製到不同的列,
(like : shipping_skudetails.itemWeight copied into shyplite.width)
我想數據列複製到列。而不是通過在查詢中排列列。
我想通過標識列名來複制數據的查詢。