DELETE after SELECT - will mysql maintain the same order? -


i've got existing code couple of queries , i'm trying figure out if functionality correct. queries performed on simple table integer unique ids stored. code first query:

select id id_table limit some_number; 

then operations on retrieved ids , removes them table:

delete id_table limit some_number; 

from understand in mysql order not guaranteed (and no order specified in there). second query delete same records retrieved in first query, given nobody else queries id_table?

thanks

you shouldn't that. fundamental problem unless use order by clause, there no guarantee of rows returned/deleted using limit.

you should use order by, in both select , delete, on same column(s), this:

select id id_table order id limit some_number;  delete id_table order id limit some_number; 

you can order want long it's consistent, id logical choice auto_increment column.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -