摘要:
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = class(TForm) DBGrid1: TDBGri... 阅读全文
摘要:
//只要前五条记录procedure TForm1.Button1Click(Sender: TObject);begin with ADODataSet1 do begin Close; CommandText := 'SELECT TOP 5 * FROM country'; Open; end;end;//去除重复procedure TForm1.Button2Click(Sender:... 阅读全文
摘要:
代码文件://分组条件可以是 Whereprocedure TForm1.Button1Click(Sender: TObject);begin with ADODataSet1 do begin Close; CommandText := 'SELECT Continent, AVG(Area) AS 平均面积 ' + 'FROM country WHERE Continent="South ... 阅读全文
摘要:
Group By本来 Group By 也可以根据多个字段分组("," 隔开), 但这个例子只有 Continent 字段适合分组, 也只有 Area、Population 字段适合统计.本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, F... 阅读全文
摘要:
本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = class(TForm) DBGr... 阅读全文
摘要:
本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = class(TForm) DBGr... 阅读全文
摘要:
Order By Asc|Desc本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = ... 阅读全文
摘要:
Where 用来指定查询条件;Like 和 Not Like 来指定模糊条件;模糊条件中:_ 表示任一字符;% 表示任一字符串;[] 表示一个集合.本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdC... 阅读全文
摘要:
//选择 country 表中的 Name 字段SELECT Name FROM country//选择 country 表中的 Name、Area 和 Population 字段SELECT Name,Area,Population FROM country{多个字段时, 字段名是用 "," 隔开的}本例效果图:代码文件:unit Unit1;interfaceuses Windows, Me... 阅读全文
摘要:
//选择 country 表中的所有字段SELECT * FROM country{虽然 SQL 并不区分大小写, 但应习惯把关键字大写}本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,... 阅读全文
摘要:
本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DB, DBClient, StdCtrls, ExtCtrls;type TForm1 = class(TForm) P... 阅读全文