一个取数据问题
我的一张数据表是这样的:
表名:info
字段名:no,no2
no no2
1 0
1 1
1 2
1 3
2 1
... ...
通过sql,把no所对应的数据取出并存入到一维数组中
例如:no=1 时,对应的no2值为:0,1,2,3,怎样把0,1,2,3存入到一维数组中
我的代码是这样的:
var
i,j,count:integer;
arr:array[0..3] of integer;
begin
with ADOQuery1 do
begin
sql.Clear;
sql.Add('select count(*) as count from info where no=''1''');
open;
count:=fieldbyname('count').AsInteger;
sql.Clear;
sql.Add('select no2 from info where no=''1''');
open;
for i:=1 to count do
begin
arr[i]:=fieldbyname('no2').AsInteger ;//这里在运行时会出错
end;