Reputation: 9753
I would like to run my UPDATE statement on my table and see what the results will be without actually changing the table.
For example:
UPDATE MyTable SET field1=TRIM(field1);
I would like to see the result of that without actually changing the tables content. Is this possible? Specifically I am asking about MySQL.
Also, I know I could just run a SELECT statement as follows:
SELECT TRIM(field1) FROM MyTable;
But I would like to know if I can do it the other way.
Upvotes: 0
Views: 485
Reputation: 1906
If you are using InnoDB tables - use a transaction. If you don't like the results, ROLLBACK - If they are OK, the COMMIT
START TRANSACTION;
UPDATE MyTable SET field1=TRIM(field1);
COMMIT; (or ROLLBACK;)
Upvotes: 4
Reputation: 268364
If you can't use a transaction, you can push the content of that table into a temporary table (insert select
), and do your update on that first.
Upvotes: 2