摘要: unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = class(TForm) DBGrid1: TDBGri... 阅读全文
posted @ 2009-05-28 23:10 万一 阅读(7575) 评论(25) 推荐(0) 编辑
摘要: //只要前五条记录procedure TForm1.Button1Click(Sender: TObject);begin with ADODataSet1 do begin Close; CommandText := 'SELECT TOP 5 * FROM country'; Open; end;end;//去除重复procedure TForm1.Button2Click(Sender:... 阅读全文
posted @ 2009-05-28 18:42 万一 阅读(3381) 评论(9) 推荐(0) 编辑
摘要: 代码文件://分组条件可以是 Whereprocedure TForm1.Button1Click(Sender: TObject);begin with ADODataSet1 do begin Close; CommandText := 'SELECT Continent, AVG(Area) AS 平均面积 ' + 'FROM country WHERE Continent="South ... 阅读全文
posted @ 2009-05-28 17:54 万一 阅读(3584) 评论(0) 推荐(0) 编辑
摘要: Group By本来 Group By 也可以根据多个字段分组("," 隔开), 但这个例子只有 Continent 字段适合分组, 也只有 Area、Population 字段适合统计.本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, F... 阅读全文
posted @ 2009-05-28 16:43 万一 阅读(4044) 评论(0) 推荐(0) 编辑
摘要: 本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = class(TForm) DBGr... 阅读全文
posted @ 2009-05-28 16:12 万一 阅读(4405) 评论(0) 推荐(0) 编辑
摘要: 本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = class(TForm) DBGr... 阅读全文
posted @ 2009-05-28 15:23 万一 阅读(4648) 评论(0) 推荐(0) 编辑
摘要: Order By Asc|Desc本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB;type TForm1 = ... 阅读全文
posted @ 2009-05-28 14:39 万一 阅读(4763) 评论(2) 推荐(0) 编辑
摘要: Where 用来指定查询条件;Like 和 Not Like 来指定模糊条件;模糊条件中:_ 表示任一字符;% 表示任一字符串;[] 表示一个集合.本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdC... 阅读全文
posted @ 2009-05-28 13:03 万一 阅读(7844) 评论(3) 推荐(1) 编辑
摘要: //选择 country 表中的 Name 字段SELECT Name FROM country//选择 country 表中的 Name、Area 和 Population 字段SELECT Name,Area,Population FROM country{多个字段时, 字段名是用 "," 隔开的}本例效果图:代码文件:unit Unit1;interfaceuses Windows, Me... 阅读全文
posted @ 2009-05-28 01:51 万一 阅读(5555) 评论(4) 推荐(0) 编辑
摘要: //选择 country 表中的所有字段SELECT * FROM country{虽然 SQL 并不区分大小写, 但应习惯把关键字大写}本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,... 阅读全文
posted @ 2009-05-28 01:40 万一 阅读(6252) 评论(7) 推荐(1) 编辑
摘要: 本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DB, DBClient, StdCtrls, ExtCtrls;type TForm1 = class(TForm) P... 阅读全文
posted @ 2009-05-28 00:00 万一 阅读(10910) 评论(20) 推荐(0) 编辑