🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.database
1 messages
1 total messages Started by missing Sun, 11 Jan 1998 00:00
sybase sql һ��
#10483
Author: missing
Date: Sun, 11 Jan 1998 00:00
30 lines
1770 bytes
��������sybase T-sql д�����ֵ�����,ϣ���Ұ��æ.
�ְ����������.
�б� test1(a int , b int)
     test2(a int , b int ,c int)
test1��Ψһ����������,test2��(a,b)Ϊ����.
���(a,b)��ֵ������test1 ��,��test2��Ӧ����(a,b,1)
���߽�ԭֵ(a,b,0)��Ϊ(a,b,1).
���ѰѲ����������,�����¾�:
insert into test2
select distinct a,b,1
from test1
where not exists(select 1 from test2
                 where test1.a = test2.a
                   and test1.b = test2.b);
(Ҳ��֪�Ƿ�������)
��Ҫ����޸ĵ�����,��test2 ����(a,b,0),Ҫ���test1�Ƿ���(a,b)��¼
������Ϊ(a,b,1).
����������:
update test2
set c = 1
where (a,b) in (select distinct a,b from test1);
����sybase�ļ��ϲ�������֧�ֶ���,ִ��ʱ���﷨��.
������ʲô���֮��?
лл!
(��Ҫ����������ͼ,��Ϊtest1�еļ�¼����ʱ��ܶ�,��test2������
����ʷ,ֻҪ���ʱ(a,b)������test1��,test2��Ҫ����(a,b,1))

--
�� ��Դ: �й�ƴ�BBSվ [bbs.ustc.edu.cn]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads