学习 SQL 语句 - Select(9): 其他


//只要前五条记录

procedure TForm1.Button1Click(Sender: TObject);

begin

  with ADODataSet1 do begin

    Close;

    CommandText := 'SELECT TOP 5 * FROM country';

    Open;

  end;

end;



//去除重复

procedure TForm1.Button2Click(Sender: TObject);

begin

  with ADODataSet1 do begin

    Close;

    CommandText := 'SELECT DISTINCTROW * FROM country';

    Open;

  end;

end;



//获取字段列表

procedure TForm1.Button3Click(Sender: TObject);

var

  i: Integer;

  str: string;

begin

  str := '';

  for i := 0 to ADODataSet1.FieldDefs.Count - 1 do

  begin

    str := str + ADODataSet1.FieldDefs[i].Name + sLineBreak;

  end;

  ShowMessage(str);

end;


 
   

你可能感兴趣的:(select)