PHP MySql Compare 2 Columns in Different Tables, Perform a Calculation & Output Result
I've got 2 tables with exactly the same structure called table_new & table_old respectively. The table structure is below:
CREATE TABLE IF NOT EXISTS `table_new` (
`Club_Number` int(11) default NULL,
`Club_Name` varchar(60) character set utf8 default NULL,
`Active_Members` int(11) default NULL,
`Goals_Met` int(11) default NULL,
`Last_Updated` date NOT NULL,
`id` int(6) NOT NULL auto_increment,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Here's what I want to do:
Step 1. Compare table_new against table_old where table_new.Active_Members is greater than table_old.Active_Members OR table_new.Goals_Met is greater than table_old.Goals_Met WHERE table_new.Club_Number equals table_old.Club_Number
Step 2. If something positive is found (the results are greater than zero), calculate the difference between:
- table_new.Active_Members and table_old.Active_Members & echo the results
- table_new.Goals_Met and table_old.Goals_Met & echo the results
How do I achieve this using PHP & MySQL? Thanks a lot for your help.
Answer
Solution:
This query will give you required output
Answer
Solution:
This query will be helpful to you
Answer
Solution:
PHP script display difference.