Query1.Close;//这里有没有Close呢?
query1.Sql.Clear;
sqlstr:='select min(Group_ID) from students where 院=化学学院';
Query1.Sql.Add(sqlstr);
Query1.Open();
GroupNum:=Query1.fieldbyname('Group_ID').asinteger;
我看看
query1.close;
Query1.Sql.Clear;
sqlstr:='select min(Group_ID) from students where 院=化学学院';
Query1.Sql.Add(sqlstr);
Query1.Open();
GroupNum:=Query1.fieldbyname('Group_ID').asinteger;
这样就应该行了吧
如果后面的没错的话
Query1.Sql.Clear;
sqlstr:='select min(Group_ID) from students where 院=化学学院';
Query1.Sql.Add(sqlstr);
Query1.Open();
GroupNum:=Query1.fieldbyname('Group_ID').asinteger;
Query1.Close; //需要增加Close
Query1.Sql.Clear;
sqlstr:='select Group_Order,姓名'+ComboBox3.Text+' from students where Group_ID='+inttostr(GroupNum);
Query1.Sql.Add(sqlstr);
Query1.Open();
请各位大侠看看这几句话有什么毛病:
Query1.Sql.Clear;
sqlstr:='select min(Group_ID) from students where 院=化学学院';
Query1.Sql.Add(sqlstr);
Query1.Open();
GroupNum:=Query1.fieldbyname('Group_ID').asinteger;
Query1.Sql.Clear;
sqlstr:='select Group_Order,姓名'+ComboBox3.Text+' from students where Group_ID='+inttostr(GroupNum);
Query1.Sql.Add(sqlstr);
Query1.Open();
to byrybye(BYRY):是我没说清楚,实际情况和你写的差不多:表内学生分若干系,每个系中又
包括若干组,每个组内有若干个学生。但是每个系内的组号不是从1往上排
也就是可能是这种情况:物理系1-9组,化学系10-23组,生物系24-31组..
现在查询条件包括:知道了系名,又知道了要选择的组是这个系中的第几组
(按A组B组C组D组E组F组...排列),要查出这一组学生的信息。
to zhuzhichao(竹之草):34-48使我假设的,实际操作中这个数可能是随机的呀,呵呵。
1.
select * from student where Group_ID =
(select min(Group_ID) from student where Group_ID between 34 and 48);
2.
select * from student where Group_ID =
(select min(Group_ID) from student where Group_ID between 34 and 48
and Group_ID not in (select min(Group_ID) from student where Group_ID between 34 and 48));
问题不明确呀,什么意思??
组是怎么分的,和系有关系吗//
可以这样了
select * from students where gruop_id like(
select min(gruop_id) as min_id form
(select * from students where 院系名称 like '化学系'))
应该行,不过我也没试过,思路应该可以,
可能效率低