tag:blogger.com,1999:blog-4975003600549562099.post7007558484760409687..comments2023-03-03T01:10:24.329-08:00Comments on MySQL Stored Procedures and Functions: How to compare the record differences of two similar tables - Part 1 of 20v34c10ckhttp://www.blogger.com/profile/08190457138541999570noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4975003600549562099.post-71205062348555972332014-11-30T09:38:19.918-08:002014-11-30T09:38:19.918-08:00Thanks for the feedback. It won't be a small t...Thanks for the feedback. It won't be a small tweak though.0v34c10ckhttp://www.blogger.com/profile/08190457138541999570noreply@blogger.comtag:blogger.com,1999:blog-4975003600549562099.post-84050597132416239102014-11-05T13:39:50.288-08:002014-11-05T13:39:50.288-08:00I know it's been a while since anyone commente...I know it's been a while since anyone commented, but I would love a version of this that only displays differences between fields (value changes) and not missing or extra rows. (i.e. ignore new data or missing data because I only care if there's a change to existing data) Is that possible with just a small tweak?<br /><br />Thanks!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4975003600549562099.post-25590296317228858892011-06-06T10:56:06.425-07:002011-06-06T10:56:06.425-07:00Hi Faisal,
Thank you.
If what you need are just ...Hi Faisal,<br /><br />Thank you.<br /><br />If what you need are just the new records, try this:<br /><br />SELECT * <br />FROM `tableB` B<br />WHERE B.`primaryKeyColumn`<br />NOT IN (<br />SELECT `primaryKeyColumn`<br />FROM `tableA` A<br />WHERE B.`primaryKeyColumn` = A.`primaryKeyColumn`<br />);<br /><br />Where you mentioned `tableB` is the one where the new records are in. You will need to input the Primary Key column/s.<br /><br />If you want to make this statement dynamic, re-write it as a dynamic SQL statement in a stored procedure and you can use the getPKColumns() user defined function to get the Primary Keys. You can find it here: <br /><br />http://mysql-0v34c10ck.blogspot.com/2011/05/better-way-to-get-primary-key-columns.html0v34c10ckhttps://www.blogger.com/profile/08190457138541999570noreply@blogger.comtag:blogger.com,1999:blog-4975003600549562099.post-9806985509310591332011-06-06T00:35:52.106-07:002011-06-06T00:35:52.106-07:00I need to compare the record differences of two si...I need to compare the record differences of two similar tables.I Saw you example its great.But I need only record from a table. Like only Change and new from new table( table B)<br />Here Table A = Old table and Table B = New Table. I want to show Table B which is not match in Table A.BH Faisalhttps://www.blogger.com/profile/01203988198028384054noreply@blogger.com