Share the post "WAMP MySQL Tables Are There But Does Not Exist When Accessed"
Bet this happened because you just reinstalled WAMP, right? This happens if you did not back up the data folder under MySQL folder.
I am not sure if there is another alternative other than if your Windows backup is running. If it is, then you are lucky.
Simply go to the data folder and look for the iblog0 and ibdata files. Right click, select restore and choose which restore point you wish to revert back.
If Windows was not able to back up those files, you are out of luck.
Share the post "Toggle 1 And 0 Values In An Update MySQL Statement"
Good thing MySQL has the IF() function that enables us to update a column by switching values to 0 if current value is 1 and vice versa in just 1 query.
UPDATE table_name SET column_name = IF(column_name = 1, 0, 1) WHERE column_name = whatever
This way, we do not have to waste resources by querying for the current value and then executing an update query.
Share the post "How To Swap Column Values Of 2 Rows In MySQL"
Setting the sort order between 2 rows in MySQL can be done in 1 line by making use of the IF() function.
I had a scenario where I had move up and move down functionalities to set the order of my database entries.
Let us say, you have columns ID and SORT_ORDER.
This line of code should do the trick.
UPDATE table SET sort_order = IF(sort_order = sortordervalue1, sortordervalue2, sortordervalue1) WHERE id IN(id1, id2)';