Reputation: 771
I just added new table in my database to track image views.. like so
viewcount
DATE
IMAGE_ID
NUMVIEWS
I don't know how in the world to add the old views that I tracked before, which was just a column Views in the image table like so..
imageTable
IMAGE_ID
NUMVIEWS // 2654 or whatever
I want to add them all as an arbitrary date.
ex: 12/21/2012
seems so complicated.. maybe should just reset all views and go on with the new table
Upvotes: 0
Views: 32
Reputation: 34055
Just INSERT
them from the old table?
INSERT INTO viewcount (date, image_id, numviews)
SELECT '2012-12-21' AS date, image_id, numviews FROM imageTable
If you want to update the actual numviews
you can try:
UPDATE viewcount
LEFT JOIN imageTable ON imageTable.image_id = viewcount.image_id
SET viewcount.numviews = viewcount.numviews + imageTable.numviews
Be aware that this will update records for any date.
Upvotes: 1