🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.database
Article #9876

Re: ����һ����ѯ

#9876
From: martin
Date: Sun, 19 Jul 1998 00:00
60 lines
3498 bytes
> ==> Xh_Y(������У)                           ˵��: 
> table1��table2�й�ͬ���ֶ�field1
> ���������table2������IJ�ѯ��
> 1��table2��ij�ֶ�field2����������field2 > ij�Զ������
> 2�����table2ij��¼��field1�����ݲ�������table1�У���Ѹ��ֶ�ѡ��
> 3�����.......................... ������ ........����
> ������Ӧ��table1�и�����¼��ij�ֶ�field2 > ij�Զ����������ѡ�ж�
> Ӧtable2���������¼
> ������vfp�����ʵ����һ��ѯ�����ѽ�������ij��grid�
> лл


�þò���foxproϵ���ˣ���֪��vfp5���ڶ�ansi sql ��֧�������ˣ������
��һ������sql
select table2.* from table2 
  where field2 > variant and                // ������
  field1 not in (select field1 from table1) // ������
union
select table2.* from table2, table1 
  where table2.field2 > variant and         //����1
  table1.field1 = table2.field1 and
  table1.field2 > variant��������������������//����3����

ע�⣺����sqlֻ��table1�е�field1��Ψһ�ֶ�ʱ�������������ϸ�������£���ʵ
�ϣ�����Ҫ��Ľ��Ҳֻ����table1��field1Ψһʱ�õ���
���vfp��֧��union����ɲ�ȡ�α꣬�Ȼ�ȡ������, ������cursor1�У�
�ٻ�ȡ����3,������cursor2�У����cursor1,cursor2�еĽ��ϲ�.
���vfp��֧��in��������ֻ������취�ˡ�

fear_all(ty,�д�Ŷ)���㷨������ڶ�������ȷ,
select temp1.* from table2, temp1 where 
   table2.field2 <> temp1.field2
����һ����������,�����ų����������˵, table1��table2����������,
variant = 1
table1                 
   field1     field2   
    1           10
    2           10
    3           10
    4           10
table2
   field1      field2 
    3            10
    3            10
    4            10
    5            10
    6            10

feal_all�ڶ����ı���Ӧ�� ��ȡtable2�еļ�¼(5,10)��(6,10),������ʵ�ʲ���
���Ϊ(1,10,3,10), (1,10,3,10),(1,10,4,10)....һ����17����¼��table2�еļ�¼
��4,10)������table1�е�(1,10),(2,10),(3,10)�ཻ���ڽ���г���3�Σ���table2
�е�������ͬ��¼(3,10)������table1�е�(1,10),(2,10),(4,10)�ֱ��ཻ���ڽ����
����6��.


     
   

--
�� ��Դ: �й�ƴ�BBSվ [bbs.ustc.edu.cn]
Technical Details
Message-ID: <980720.yy0iT$PBBS@bbs.ustc.edu.cn>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB
X-Google-Thread: 101948,1da1ab9075cbec99
X-Google-Attributes: gid101948,public
From: Jinye_Martin@bbs.ustc.edu.cn (martin)
Subject: Re: ����һ����ѯ
Date: 1998/07/19
Message-ID: <980720.yy0iT$PBBS@bbs.ustc.edu.cn>
X-Deja-AN: 372973925
Organization: �й�ƴ�BBSվ
Newsgroups: cn.bbs.comp.database