title: How to select two MySQL rows and then compare a column and return an output
body: <p>I've a table with a structure something like this,</p>
  
  <pre><code>Device | paid | time
  abc       1    2 days ago
  abc       0    1 day ago
  abc       0    5 mins ago
  </code></pre>
  
  <p>Is it possible to write a query that checks the paid column on all the rows where <code>Device = abc</code> and then outputs the most recent two rows that different. Basically, something like an if statement saying if row 1 = 1 and row 2 = 0 output that but only if it's the most recent two columns that are different. For example, in this case, the first and second row. The table is being updated whenever a user changes from a free to paid account etc. It is also updated in different columns for different reasons hence the duplicate 0s for example. </p>
  
  <p>I know this would probably be done better by having another table altogether and updating that every time the user switches account type, but is there any way to make this work?</p>
  
  <p>Thanks</p>