PHP MYSQL Detect if new row is added -


any idea how can identify if there new client added on database.

i thinking identifying thru date_added field.

id    client_name     date_added --------------------------------- 1     abc             2013-01-02 2     xyz             2013-01-03  3     efg             2013-01-02 4     hij             2013-01-05 

as can see new client added hij on 2013-01-05.

i looking kind of result:

client list total no: 4 new client total no: 1 client name: hij 

it's hard tell based on comment ...my reference date 1 month interval... might looking this

select id, client_name, new_count, total_count   (   select id, client_name     clients    date_added between curdate() - interval 1 month , curdate() ) c cross join (   select    (     select count(*) new_count         clients          date_added between curdate() - interval 1 month , curdate()   ) new_count,   (     select count(*) total_count         clients   ) total_count ) t  

obviously can change curdate() other reference date in past in query , results date.

lets assume have following sample data

 +------+-------------+------------+ | id   | client_name | date_added | +------+-------------+------------+ |    1 | abc         | 2013-05-13 | |    2 | xyz         | 2013-06-13 | |    3 | efg         | 2013-06-13 | |    4 | hij         | 2013-08-11 | +------+-------------+------------+ 

and today 2013-08-13 output query be

 +------+-------------+-----------+-------------+ | id   | client_name | new_count | total_count | +------+-------------+-----------+-------------+ |    4 | hij         |         1 |           4 | +------+-------------+-----------+-------------+ 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -