学习 SQL 语句 - Insert、Update、Delete
摘要: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
万一
阅读(7580)
推荐(0) 编辑
学习 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:...
阅读全文
posted @
2009-05-28 18:42
万一
阅读(3383)
推荐(0) 编辑
学习 SQL 语句 - Select(8): 分组条件
摘要:代码文件://分组条件可以是 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
万一
阅读(3586)
推荐(0) 编辑
学习 SQL 语句 - Select(7): 分组统计之 Avg()、Sum()、Max()、Min()、Count()
摘要:Group By本来 Group By 也可以根据多个字段分组("," 隔开), 但这个例子只有 Continent 字段适合分组, 也只有 Area、Population 字段适合统计.本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, F...
阅读全文
posted @
2009-05-28 16:43
万一
阅读(4050)
推荐(0) 编辑
学习 SQL 语句 - Select(6): 字段运算
摘要:本例效果图:代码文件: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
万一
阅读(4408)
推荐(0) 编辑
学习 SQL 语句 - Select(5): 字段别名
摘要:本例效果图:代码文件: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
万一
阅读(4652)
推荐(0) 编辑
学习 SQL 语句 - Select(4): 排序
摘要: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
万一
阅读(4764)
推荐(0) 编辑
学习 SQL 语句 - Select(3): 条件查询与模糊查询
摘要:Where 用来指定查询条件;Like 和 Not Like 来指定模糊条件;模糊条件中:_ 表示任一字符;% 表示任一字符串;[] 表示一个集合.本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdC...
阅读全文
posted @
2009-05-28 13:03
万一
阅读(7849)
推荐(1) 编辑
学习 SQL 语句 - Select(2): 指定表中的字段
摘要://选择 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
万一
阅读(5559)
推荐(0) 编辑
学习 SQL 语句 - Select(1): 指定表
摘要://选择 country 表中的所有字段SELECT * FROM country{虽然 SQL 并不区分大小写, 但应习惯把关键字大写}本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,...
阅读全文
posted @
2009-05-28 01:40
万一
阅读(6259)
推荐(1) 编辑
使用 TClientDataSet(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
万一
阅读(10920)
推荐(0) 编辑