Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/49372-comparing-2-rows-in-mysql/
Share on other sites

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?

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:) )

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.

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.

   

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.