我需要一些例子@@fetch_status值-2和-9
0 = The FETCH statement was successful.
-1 = The FETCH statement failed or the row was beyond the result set.
Run Code Online (Sandbox Code Playgroud)
这是一个示例游标示例
declare @country varchar(50)
declare cur_country cursor for
select name from global
open cur_country
fetch next from cur_country into @country
print @@FETCH_STATUS
while (@@FETCH_STATUS=0)
begin
insert into country select @country
fetch next from cur_country into @country
end
close cur_country
deallocate cur_country.
Run Code Online (Sandbox Code Playgroud)
-2 提取的行丢失了.
-9 游标未执行获取操作.
基本上需要@@FETCH_STATUS给出-20r的场景-9
我有一个这样的查询
SELECT COUNT(u.user_id) AS count1 FROM users WHERE user_id>1001
UNION
SELECT COUNT(c.hits) AS count2 FROM source c WHERE loginid LIKE 'fb%';
Run Code Online (Sandbox Code Playgroud)
结果
count1
250
56
Run Code Online (Sandbox Code Playgroud)
怎么能做成这样的单行
count1 count2
250 56
Run Code Online (Sandbox Code Playgroud) 如果条件匹配,如何在一段时间间隔后更新表格?
tb_contest id contest_id name is_expire 1 101 new 0 2 102 old 0 tb_answer contest_id answer_id date 101 1 2012-02-02 101 2 2012-09-14 102 5 2012-06-01
我需要tb_contest在满足某些条件后更新,并is_expire=1根据收到的最后一个答案在2天后进行更新:2012-03-14所以tb_contest应该更新2012-09-16.
我在 MYSQL 数据库中有一个名为 apps 的表。
| ID | 来源 |
|---|---|
| 1 | 脸书 |
| 2 | 总督 |
| 3 | TW |
| 4 | 脸书 |
| 5 | 曲 |
| 6 | 脸书 |
我想要一个查询来提供总计数和fb计数
| 总数 | 来源 |
|---|---|
| 6 | 3 |