Bookmark and Share
insert select ON DUPLICATE KEY UPDATE from the same table
(Publish Date: 2012-4-23 12:35pm, Total Visits: 870, Today: 1, This Week: 5, This Month: 6)

insert on duplicate

insert into test (id, fa_id, value, date, updated_by)
select t2.id, t2.fa_id, t2.value, t2.date, t2.updated_by
from test t2
ON DUPLICATE KEY UPDATE
test.fact_value = if(t2.factvalue= 1, 'Y', 'N'), date=now();