In this post I would like to share my views on how swapping column values in MySQL table. Recently I have a requirement that one record should be active mode in the given point of time remaining records should be in inactive mode. I have got the solution for it. So I would like to share my views on it. Swapping column values in MySQL table by Anil Kumar Panigrahi MySQL table : CREATE TABLE IF NOT EXISTS users ( id int ( 11 ) NOT NULL AUTO_INCREMENT , status varchar ( 20 ) DEFAULT NULL , PRIMARY KEY ( id ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 ; Sample data to the table : INSERT INTO users ( id , status ) VALUES ( 1 , 'inactive' ) , ( 2 , 'inactive' ) , ( 3 , 'inactive' ) , ( 4 , 'inactive' ) , ( 5 , 'active' ) ; here we have one active ...
here are many ways to maintain the revisions using PHP and MySQL. I am going to explain with a small example for how to make revisions of your content using PHP. How to make revisions of your content using PHP by Anil Labs – an Anil Kumar Panigrahi’s tech blog Take database tables as contents table: -- -- Table structure for table `contents` -- CREATE TABLE `contents` ( `id` int ( 11 ) NOT NULL , `title` varchar ( 255 ) NOT NULL , `revision _ id` int ( 11 ) NOT NULL , `updated _ date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE = InnoDB DEFAULT CHARSET = utf8 ; -- -- Indexes for dumped tables -- -- -- Indexes for table `contents` -- ALTER TABLE `contents` ADD PRIMARY KEY ( `id` ) ; -- -- AUTO_INCREMENT for dumped ta...