我正在做一個mysql事件中的select,然後試圖用該選擇中的數據更新另一個表。但它似乎並沒有工作。在Mysql事件中做選擇和更新
我做:
BEGIN
select read_pub_id, read_artc_id, count(read_artc_id) as times_read from reads_t GROUP BY read_pub_id, read_artc_id;
update reads_totals set read_total = times_read where pub_id = read_pub_id and artc_id = read_artc_id;
update reads_totals set ts=now(); /*This is for testing*/
END
只有TS得到更新。這意味着事件正在發揮作用。
是否有一個while循環被添加到這裏,以及如何?什麼是正確的方法來做到這一點?
我以往關於這個問題是在這裏:
所以,如果我這樣做,我不需要在那裏使用select語句? – Norman
不需要選擇語句,如果你這樣做 – SRIRAM