In the beginning of my Magento WebStore experience, I had many test orders that I would submit to test out features and tweaks that I had implemented into my web store. However, this was often done after the site had already gone live, and I couldn’t necessarily just empty my entire database file via phpMyAdmin, otherwise I would lose all that data. So the question became “How can I remove these test orders from my sales figures, but not mess with the legitimate sales and data that I wanted to keep?” This is where a good knowledge of SQL comes in. Most Magento users really don’t even take into account that everything is stored in a database and can be hand-edited via phpMyAdmin, but it is and can.
To remove an order, no matter what its status, all you need is access to be able to execute SQL querys (usually via phpMyAdmin) and some specific info about the order in question. Specifically, the order number is what you need the most (the more data the better – that way you can be SURE that you are removing the expected order.)
Once you have your order number, and you are connected to your Magento SQL Database, execute the following command to verify that that is the order that you want to delete. This should be clear, but in case it isn’t, you need to replace INSERT_ORDER_NUMBER_HERE with your order number.
select * from `sales_order` where `increment_id` = INSERT_ORDER_NUMBER_HERE ;
Check the output of that query, and make sure that the order number is indeed for the order you want to delete. Once verified, execute the following command. (Please note, SQL commands cannot just be ‘undone.’ There are precautions you should take before you EVER do SQL querys on a live site database. Namely, backup your database files! More info on that coming soon.)
delete from `sales_order` where `sales_order`.`increment_id`= INSERT_ORDER_NUMBER_HERE limit 1 ;
Enjoy!


