select into并添加到存储过程mysql中变量的当前值

时间:2017-08-10 08:02:55

标签: mysql

我想获得变量中两个表中记录数的总和。以下是代码:

removeFacilities

有没有办法在loginToTwitter() query = 'a string' tweet_cursor= tweepy.Cursor(api.search, query, result_type="recent").items() print("Searching") for tweet in tweet_cursor: tweetText = tweet.text.lower() if "rt" in tweetText: if tweet.retweeted == True: #It return me each time a false boolean but then I get the api.code 327 from twitter print("already retweeted") continue try: api.retweet(tweet.id) print('Retweedted') time.sleep(2) except tweepy.TweepError as e: if e.api_code == 327: print("Tried but tweet already Retweeted" ) print(e) time.sleep(0.5) continue 中直接选择和添加table2计数而不创建declare v_sum int default 0; declare v_count2 int default 0; select count(*) into v_sum from table1; select count(*) into v_count2 from table2; set v_sum = v_sum + v_count2; 变量。

2 个答案:

答案 0 :(得分:1)

您可以直接使用查询,例如:

SET v_sum = v_sum + (SELECT COUNT(*) FROM table2);

答案 1 :(得分:0)

避免变量的一种方法可能是:

select v_sum + count(*) into v_sum
from table2;