Zabbix MariaDB Copy item data to another item
After some digging, I managed to successfully copy history and trends from one item to another.
The sort of syntax I used is this:
History table:
INSERT INTO history (`itemid`, `clock`, `value`, `ns`)
SELECT '&lt;new_itemid&gt;', `clock`, `value`, `ns`
FROM history
WHERE itemid = &lt;old_itemid&gt;;

Trends table:
INSERT INTO trends (`itemid`, `clock`, `num`, `value_min`, `value_avg`, `value_max`)
SELECT '&lt;new_itemid&gt;', `clock`, `num`, `value_min`, `value_avg`, `value_max`
FROM trends
WHERE itemid = &lt;old_itemid&gt;;

The secret was with INSERT INTO and the SELECT clause that added the literal itemid.
The actual &lt;new_itemid&gt; was inserted into every new row.
The result:
MariaDB [zabbix]&gt; INSERT INTO trends (`itemid`, `clock`, `num`, `value_min`, `value_avg`, `value_max`) SELECT '32041', `clock`, `num`, `value_min`, `value_avg`, `value_max` FROM trends WHERE itemid = 30886;
Query OK, 5227 rows affected (0.14 sec)
Records: 5227 Duplicates: 0 Warnings: 0

MariaDB [zabbix]&gt; INSERT INTO history (`itemid`, `clock`, `value`, `ns`) SELECT '32041', `clock`, `value`, `ns` FROM history WHERE itemid = 30886;
Query OK, 2008 rows affected (0.10 sec)
Records: 2008 Duplicates: 0 Warnings: 0

I bet there's a better way, but this is all I could come up with for now.