0

The state of these two row are set to 1. I want to set them to 0 and visualizing the result of a rollback query . This query does the job :

START TRANSACTION;
UPDATE jkm_content SET state=0 WHERE title IN ('001','002');
SELECT * FROM jkm_content WHERE title IN ('001','002'); 

-> The state of the rows outputted are set to 0

However, it's better to close the start transaction with ROLLBACK but when my query is...

START TRANSACTION;
UPDATE jkm_content SET state=0 WHERE title IN ('258.txt','259.txt');
SELECT * FROM jkm_content WHERE title IN ('258.txt','259.txt');
ROLLBACK;

-> ... the state of the rows outputted are set to 1 (the current set not the start transaction one! )

What should be my query to output state=0 even if I end my query with rollback ?

JinSnow
  • 1,553
  • 4
  • 27
  • 49
  • You write commit in the first phrase, but later you mention rollback. I think you mix something. Or at least your intention is not clear for me. – Lajos Veres Nov 10 '13 at 15:52
  • Thanks for your comment. I edited the question. I used commit because -to me- the rollback query if like a draft before the commit query. Maybe it'snt the way it should be used but I guess it does the job! – JinSnow Nov 10 '13 at 16:07

1 Answers1

0

Rollback means go back in time to the beginning of the transaction. Everything happened between the start transaction and the rollback will be discarded. I think you need a save checkpoint or similar feature. (I don't know whether it exists under mysql or not.)

Lajos Veres
  • 13,595
  • 7
  • 43
  • 56