<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Code Spatter - Latest Comments in How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.disqus.com/</link><description></description><atom:link href="https://codespatter.disqus.com/how_to_use_triggers_to_track_changes_in_mysql/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 29 Mar 2018 04:26:08 -0000</lastBuildDate><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-3829523071</link><description>&lt;p&gt;Thanks. I also looking for your new updates. Thanks for your help&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Easy Set Pools</dc:creator><pubDate>Thu, 29 Mar 2018 04:26:08 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-3821602635</link><description>&lt;p&gt;Hi,&lt;br&gt;I can help with modification. PM me for solution.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">matching shirts for couples</dc:creator><pubDate>Sat, 24 Mar 2018 03:13:16 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-3644424084</link><description>&lt;p&gt;This seems to work well from my side. Thanks. I also looking for your new updates. Thanks for your help&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">masterbuilt</dc:creator><pubDate>Sun, 03 Dec 2017 08:32:22 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-3200167922</link><description>&lt;p&gt;Pla i av dis error on my phpmyadmin when importing, pls help me&lt;/p&gt;&lt;p&gt;CREATE TABLE IF NOT EXISTS `wpf8_commentmeta` (&lt;br&gt;  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,&lt;br&gt;  `comment_id` bigint(20) unsigned NOT NULL DEFAULT '0',&lt;br&gt;  `meta_key` varchar(255) DEFAULT NULL,&lt;br&gt;  `meta_value` longtext,&lt;br&gt;  PRIMARY KEY (`meta_id`),&lt;br&gt;  KEY `comment_id` (`comment_id`),&lt;br&gt;  KEY `meta_key` (`meta_key`(191))&lt;br&gt;) TYPE=MyISAM  AUTO_INCREMENT=96 ;&lt;br&gt;MySQL said: Documentation&lt;/p&gt;&lt;p&gt;#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM  AUTO_INCREMENT=96' at line 19&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abiola Joseph Efficacy</dc:creator><pubDate>Sun, 12 Mar 2017 08:01:22 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-955034436</link><description>&lt;p&gt;Different point of view from that post. Interesting to say the least.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">yepi250</dc:creator><pubDate>Mon, 08 Jul 2013 03:31:31 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-453096374</link><description>&lt;p&gt;Thank you very much. Perfectly resolved my issue.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guest</dc:creator><pubDate>Thu, 01 Mar 2012 01:35:10 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-280416608</link><description>&lt;p&gt;Quick word on this, I recently started working on an application using the mysql extension, and one of my first required steps was to change to mysqli, not having multiple queries possible is a huge problem, and clearly the mysql extension has quite a few other major flaws one should not attempt to live with. (and god bless postgresql, for it has only one extension, which works perfectly fine)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">L.</dc:creator><pubDate>Mon, 08 Aug 2011 10:01:52 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-176189001</link><description>&lt;p&gt;As a bit of a follow up....  I guess the way that it is currently set up it would insert two times into the history_clients table if your UPDATE contained a change to the first AND last name.  Maybe there is a reason for doing this, but I would think that reflecting BOTH changes in one row in the history_clients table would be the way to go.  That is why I am wondering if we could somehow combine them.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rick</dc:creator><pubDate>Fri, 01 Apr 2011 10:56:22 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-176182125</link><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;I am wondering if there is a way to combine the 2 if statements in the MySQL trigger.  Instead of having one to check and see if there has been a change to the first name and a SEPARATE check to see if there has been a change to the last name would it be possible to combine them?&lt;/p&gt;&lt;p&gt;I guess what I am asking is if MySQL can support a structure such as IF( A != B || C != D){...  If "a" or "b" is the following...  or even an IF (A != B &amp;amp;&amp;amp; C != D){...  If "a" and "b" do the following.&lt;/p&gt;&lt;p&gt;Thanks in advance,&lt;br&gt;Rick&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rick</dc:creator><pubDate>Fri, 01 Apr 2011 10:40:06 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-139341515</link><description>&lt;p&gt;Thanks for sharing your mind with us.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">how to get pregnant fast</dc:creator><pubDate>Thu, 03 Feb 2011 01:40:29 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-89319169</link><description>&lt;p&gt;-using phpmyadmin actuly im using xampplite wuold u help me?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ana30soberano</dc:creator><pubDate>Fri, 22 Oct 2010 23:29:01 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-89318977</link><description>&lt;p&gt;-hai would u,,,create simple log in,,that if the username is wrong...then,,,the echo wuold be wrong pass and username?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ana30soberano</dc:creator><pubDate>Fri, 22 Oct 2010 23:27:57 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-47876489</link><description>&lt;p&gt;great to have found this site.  I have used all search engines to find someone trying to update a table based on input changes.  My issue was:&lt;br&gt;1- keep loading a table everyday.  &lt;br&gt;2- data rows that is to load the table are repetitive.  Not all of them change in value&lt;br&gt;3- once i use insert .... on duplicate key update .  The table updates with the new information irrespective whether the values are equal or not.  I am not sure why, but I have a timestamp field among the fields.  And, i am passing a current_timestamp() function in the insert statement.  This is needed to timestamp new records, and timestamp the duplicate key records if any of their values differ. &lt;br&gt;What I ended up getting, an updated timestamp that is always current.  I lose track whether a real change exist in the values themselves. I think timestamp fields update with a timestamp irrespective whether other values change, that's because the timestamp field by itself changed.  Enough to execute the update.  This is the first caveat.  What I really want is to leave the row unchanged based on the values i am checking and reset the timestamp to the old one.&lt;br&gt;so, the trigger helped me achieve that by putting an if then else statement.  Similar to the above, yet introduced the else and SET new.timestamp = old.timestamp, new.counter=old.counter.  My if checks all the values that might have changes with &lt;br&gt;IF NEW.VALUE&amp;lt;&amp;gt;OLD.VALUE OR NEW.VALUE_1 &amp;lt;&amp;gt; OLD.VALUE_1 for all values ..., &lt;br&gt;THEN INSERT INTO history_table SELECT * FROM table WHERE identifiers are =.. &lt;br&gt;(The OLD.* didn't work.)&lt;br&gt;ELSE SET NEW.TIMESTAMP=OLD.TIMESTAMP, NEW.COUNTER=OLD.COUNTER&lt;/p&gt;&lt;p&gt;That did the magic, because it neutralized the new buffer to the old buffer and the update needn't to execute.&lt;/p&gt;&lt;p&gt;Hope that helps those who have the same issue.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ali</dc:creator><pubDate>Sat, 01 May 2010 12:37:18 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-30860760</link><description>&lt;p&gt;perfect... exactly what I was looking for.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anthony</dc:creator><pubDate>Fri, 22 Jan 2010 06:58:24 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-22804848</link><description>&lt;p&gt;Yeah Dear, the concept you entered is so helpful, well good work.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Phani Kumar Varanasi</dc:creator><pubDate>Thu, 12 Nov 2009 00:24:16 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-13543404</link><description>&lt;p&gt;Thank you very much!!! it saved my day &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">abhinavzone</dc:creator><pubDate>Wed, 29 Jul 2009 12:57:23 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-8429004</link><description>&lt;p&gt;I don't think there is anyway to do it in the database, but you can still put the logic in your application. If you are using django, there are signals that will help get that done. &lt;a href="http://docs.djangoproject.com/en/1.0/topics/signals/" rel="nofollow noopener" target="_blank" title="http://docs.djangoproject.com/en/1.0/topics/signals/"&gt;http://docs.djangoproject.c...&lt;/a&gt; If you aren't then you will need to program it into your project in some other way.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Greg Allard</dc:creator><pubDate>Mon, 20 Apr 2009 12:18:54 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-8423999</link><description>&lt;p&gt;Does any way work as trigger in mysql 4.1? I know that triggers is supported from mysql 5.0 &lt;br&gt;thanks for help&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sean</dc:creator><pubDate>Mon, 20 Apr 2009 12:03:18 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-3411316</link><description>&lt;p&gt;OLD and NEW are used on UPDATE triggers. OLD.col_names will access the data that is in the row of the database before the UPDATE query runs and NEW.col_names will access the data that the row will be updated to.&lt;/p&gt;&lt;p&gt;IF OLD.first_name != NEW.first_name&lt;/p&gt;&lt;p&gt;That checks if the UPDATE query is changing the information for first_name.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Greg Allard</dc:creator><pubDate>Fri, 31 Oct 2008 13:50:08 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-3408217</link><description>&lt;p&gt;hi ,&lt;br&gt;please can u explain what is &lt;br&gt;OLD.first_name != NEW.first_name&lt;br&gt;are they table names?&lt;br&gt;I need to write  atrigger to get the changed row and also how do i get the same query either insert,update or delete.&lt;br&gt;thanks in advance &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">mysqlearner</dc:creator><pubDate>Fri, 31 Oct 2008 10:33:53 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-2778096</link><description>&lt;p&gt;php's mysql improved function is the only way I have tested doing multiple queries like this in a php script. Some PEAR libraries might be able to help also. Are you in a situation where you can't use mysqli?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Greg Allard</dc:creator><pubDate>Wed, 01 Oct 2008 10:06:05 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-2775112</link><description>&lt;p&gt;Really help full. But, this is the way to execute multiple query using sqli, but what about mysql&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dhiraj Das</dc:creator><pubDate>Wed, 01 Oct 2008 08:50:12 -0000</pubDate></item><item><title>Re: How To Use Triggers to Track Changes in MySQL</title><link>http://codespatter.com/2008/05/06/how-to-use-triggers-to-track-changes-in-mysql/#comment-1720543</link><description>&lt;p&gt;Someone posted this on a link sharing site and there has been some discussion going on there. &lt;a href="http://news.ycombinator.com/item?id=182529" rel="nofollow noopener" target="_blank" title="http://news.ycombinator.com/item?id=182529"&gt;http://news.ycombinator.com...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Greg Allard</dc:creator><pubDate>Tue, 06 May 2008 19:07:14 -0000</pubDate></item></channel></rss>