I have a table named menu_click_count
on the front end. It has two columns which is name
and count
. name
column has the names of fields like dashboard
,travellers
,hotels
,etc. Now I want to update any of these fields so that the count
value for that row should be increased by one.
I have already inserted names of fields. Now what I am trying to do is to update the count field by one. Here count fields contains a number
CREATE TABLE IF NOT EXISTS menu_click_count(name,count)
INSERT INTO menu_click_count (name) VALUES ('dashboard')
INSERT INTO menu_click_count (name) VALUES ('travellers')
INSERT INTO menu_click_count (name) VALUES ('flight')
INSERT INTO menu_click_count (name) VALUES ('hotels')
INSERT INTO menu_click_count (name) VALUES ('trips')
When I update a row I can use update query but it will be static and I want it to be dynamic so that it increases it's own value by one on update query. Is there any optimum way to do this dynamically
UPDATE table SET cnt=cnt+1 WHERE xxx='zzz';