0
我有結構化的,像這樣的表(post_order):SQL查詢的字段值複製到同一臺
| post_id | term_id | post_type | taxonomy |
| 1 | 6 | post | category |
| 2 | 6 | post | category |
| 3 | 6 | post | category |
我想所有字段複製到同一個表,但是改變term_id(比方說,例如,7),因此,該表將最終看起來像這樣:
| post_id | term_id | post_type | taxonomy |
| 1 | 6 | post | category |
| 2 | 6 | post | category |
| 3 | 6 | post | category |
| 1 | 7 | post | category |
| 2 | 7 | post | category |
| 3 | 7 | post | category |
我知道我可以做這樣的事情:
INSERT INTO post_order (post_id, term_id, post_type, taxonomy)
SELECT post_id, term_id, post_type, taxonomy
FROM post_order
WHERE term_id = 6
但是,這會使一個確切的重複,而不是改變term_id。
我該如何做到這一點?