I have a table (post_order) structured like so:
| post_id | term_id | post_type | taxonomy |
| 1 | 6 | post | category |
| 2 | 6 | post | category |
| 3 | 6 | post | category |
I’d like to copy all of the fields to the same table, but change the term_id (say, for example, 7) so, the table would end up looking like this:
| 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 |
I know I could do something like:
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
But this would make an exact duplicate and not change the term_id.
How can I achieve this?
hard code the
term_idto 7 in yourINSERTstatement: