From e8c337cef0336270f32a75766111f29ef388778c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=9F=B1=E8=8F=98?= <2365839121@qq.com> Date: Fri, 7 Oct 2022 05:33:32 +0000 Subject: [PATCH] =?UTF-8?q?35=20=E9=BB=84=E6=9F=B1=E8=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄柱菘 <2365839121@qq.com> --- .../2022-9-30 \346\270\270\346\240\207.sql" | 56 +++++++++++++++++++ ...\256\260--\346\270\270\346\240\207.md.url" | 2 + 2 files changed, 58 insertions(+) create mode 100644 "35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022-9-30 \346\270\270\346\240\207.sql" create mode 100644 "35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022.9.30\347\254\224\350\256\260--\346\270\270\346\240\207.md.url" diff --git "a/35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022-9-30 \346\270\270\346\240\207.sql" "b/35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022-9-30 \346\270\270\346\240\207.sql" new file mode 100644 index 0000000..b717b8d --- /dev/null +++ "b/35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022-9-30 \346\270\270\346\240\207.sql" @@ -0,0 +1,56 @@ +--3ʹαʵּн +--α +declare cur_id cursor scroll for select PeopleId from People +--α +open cur_id +--ȡ +declare @id int, @money money = 1000 +fetch first from cur_id into @id +while (@@fetch_status = 0) + begin + update People set PeopleSalary += @money where PeopleId = @id + fetch next from cur_id into @id + end +--رα +close cur_id +select * from People +go + +--4:ʹαɾԱ +select * from People +-- +declare cur_id cursor scroll for select PeopleId,PeopleSalary from People +-- +open cur_id +--ȡ +declare @id int, @money money +fetch first from cur_id into @id,@money +while(@@FETCH_STATUS = 0) + begin + if(@money < 10000) + begin + delete People where PeopleId = @id + fetch next from cur_id into @id,@money + end + else + fetch next from cur_id into @id,@money + end +close cur_id +select * from People +go +--ʹα ʵ:ABIDֵֶͬôBеʡݣ ޸ijAеijһ£ + +declare cur_id cursor scroll for select A.* from A inner join B on A.id = B.id +deallocate cur_id +open cur_id +declare @id int , @id1 int,@Province varchar(10),@City varchar(10) +fetch first from cur_id into @id,@Province,@City +while(@@FETCH_STATUS = 0) + begin + update B set B.Province = @Province , B.City = @City where B.id = @id + fetch next from cur_id into @id,@Province,@City + end + +close cur_id +select * from A +select * from B \ No newline at end of file diff --git "a/35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022.9.30\347\254\224\350\256\260--\346\270\270\346\240\207.md.url" "b/35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022.9.30\347\254\224\350\256\260--\346\270\270\346\240\207.md.url" new file mode 100644 index 0000000..fc6309f --- /dev/null +++ "b/35\351\273\204\346\237\261\350\217\230/\351\273\204\346\237\261\350\217\23035/2022.9.30\347\254\224\350\256\260--\346\270\270\346\240\207.md.url" @@ -0,0 +1,2 @@ +[InternetShortcut] +URL=https://gitee.com/level-21-software-class-4/advanced-sql/blob/master/38%E5%BC%A0%E5%85%88%E6%9D%B0/%E7%AC%94%E8%AE%B0/2022.9.30%E7%AC%94%E8%AE%B0--%E6%B8%B8%E6%A0%87.md -- Gitee