INSERT INTO table_name WITH cte (col1) AS ( INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3) ) SELECT col1 FROM cte ON DUPLICATE KEY UPDATE col_name = 3