tags:

views:

43

answers:

2

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.

+2  A: 

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.

Jonathan Sampson
+4  A: 

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;)
DrewM