I am making a daily counter for a blog and I have problem with this query :
IF EXISTS SELECT * FROM tableA WHERE blog_id=1
UPDATE FROM tableA SET c=c+'1' WHERE blog_id='1' AND c_date=NOW()
ELSE
INSERT INTO FROM tableA VALUES (blog_id,c,c_date) VALUES (1,1,now())
its showing following error :
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'IF EXISTS SELECT * FROM tableA WHERE blog_id=1 UPDATE FROM tableA SET c=c+'' at line 1
My table entries should look like this :
id , blod_id , c , c_date
1 , 1001, 66 , 2011-11-11
2 , 1001, 160 , 2011-11-12
3 , 1002, 200 , 2011-11-12
4 , 1003, 33 , 2011-11-12