Comparing two fields in MySQL
I have built a simple website that grabs data from MySQL. The site uses the Twitter API to grab data about a users account, i.e. number of followers. I am fetching the data once a day and storing the results as a new entry in the table. The goal is to be able to show trending over time. I have successfully create a MySQL query to display the latest result but now would like to compare the latest entry with the last entry (or an entry from a specific date) to see how it has changed.
A simplified version of the table looks like this
Twitter_handle | Followers | date_of_last_update
handle1 | 1,100 | 2012-02-17 15:36:31
handle1 | 1,110 | 2012-02-18 15:25:00
I would like to display on the page that handle1 increased by 10 since the last entry.
Should this be handled as a SQL query or should I be doing something with PHP.
Thanks in advance.