woolyg Posted April 30, 2007 Share Posted April 30, 2007 Hi all, Just a non-urgent conversation piece more than anything: I'm looking around for some sort of app/utility that will take data from 2 rows in a MySQL table, and compare them, populating a visual or numeric report on the data. Has anyone here ever used/seen/developed such an app? I'd be mighty interested in hearing from anyone that has. Cheers all, Woolyg Quote Link to comment https://forums.phpfreaks.com/topic/49372-comparing-2-rows-in-mysql/ Share on other sites More sharing options...
btherl Posted May 1, 2007 Share Posted May 1, 2007 That description is very general.. do you have something more specific in mind? Are you looking at changes between two rows that differ over some axis (like time or location)? Are graphs and tables the most common visual and numeric reports you want to generate? And is it only ever 2 rows, or sometimes 3 or more? Quote Link to comment https://forums.phpfreaks.com/topic/49372-comparing-2-rows-in-mysql/#findComment-242049 Share on other sites More sharing options...
woolyg Posted May 1, 2007 Author Share Posted May 1, 2007 It's only ever 2 rows (or 2 corresponding values in 2 rows) - I would like to basically use such a utility to show which row entry has the greater value. Example table: Row | Name | Age | Salary 1. | John | 26 | 55000 2. | Henry | 28 | 60000 - I'd like to specify it to show which Age and Salary is higher, or a graphical interpretation of the same (I'll be using it for rows that have up to 200 columns, so manually checking it won't be possible:) ) Quote Link to comment https://forums.phpfreaks.com/topic/49372-comparing-2-rows-in-mysql/#findComment-242052 Share on other sites More sharing options...
bubblegum.anarchy Posted May 1, 2007 Share Posted May 1, 2007 Finding a ready made script for something so specific will be difficult... so many variables - how do you define what two records should be compared? Maybe there is something out there that will plot a graph for a single sorted field for all records in a table, even writing something that does the graphing may not be a difficult task but once, not only conditional comparisons but also conditional records is introduced, the result is a complicated script that is unlikely to exist. Quote Link to comment https://forums.phpfreaks.com/topic/49372-comparing-2-rows-in-mysql/#findComment-242122 Share on other sites More sharing options...
trecool999 Posted May 1, 2007 Share Posted May 1, 2007 It's only ever 2 rows (or 2 corresponding values in 2 rows) - I would like to basically use such a utility to show which row entry has the greater value. Example table: Row | Name | Age | Salary 1. | John | 26 | 55000 2. | Henry | 28 | 60000 - I'd like to specify it to show which Age and Salary is higher, or a graphical interpretation of the same (I'll be using it for rows that have up to 200 columns, so manually checking it won't be possible:) ) $sql = 'SELECT * FROM table ORDER BY Salary'; $result = mysql_query($sql) or die('ERROR! ' . mysql_error()); while($higher = mysql_fetch_assoc($result)) { echo $higher['Name'] . ' | ' . $higher['Age'] . ' | ' . $higher['Salary']; } Scribbling this off the top of my head, I doubt this will work, but it looks ok. Quote Link to comment https://forums.phpfreaks.com/topic/49372-comparing-2-rows-in-mysql/#findComment-242691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.