RE: Getting rows where column has changed?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I'm trying to make a page to help in detecting people using automatic
> refresher programs.  In the table that stores user info, there is a
> column called "lastseen" which says when the user was last seen.  I'm
> trying to:
> 1. Select all lastseen colmns that are less than 5 minutes old
> 2. Wait 2 seconds
> 3. Select lastseen columns that have changed since step 1, and display
> that info
> Any ideas on how to do this?  Is it even possible?  Thanks...

Temp tables would probably work great here... I'm assuming mysql, but
the logic should work with any db. 

<?
//untested code:

$result = mysql_query("CREATE TEMPORARY TABLE temp (PRIMARY KEY (id))
SELECT id, lastseen FROM table WHERE lastseen > NOW() - INTERVAL 5
MINUTE");

sleep(2);

$result = mysql_query("SELECT table.* FROM table, temp WHERE table.id =
temp.id AND table.lastseen != temp.lastseen");


Then parse the results of the second query and it should give you those
rows that have changed in 2 seconds. 

---John Holmes...



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux