子查询行不?
Examp:
SELECT lngBaseInfoTypeID,BaseInfo.strBaseInfoCode from  BaseInfo
where lngBaseInfoTypeID in (select lngBaseInfoTypeID from BaseInfo)
order by  lngBaseInfoTypeID

解决方案 »

  1.   

    sql = "SELECT lngBaseInfoTypeID,BaseInfo.strBaseInfoCode from  BaseInfo where lngBaseInfoTypeID in (select lngBaseInfoTypeID from BaseInfo) Order By" + order_field_name(Index, 0)我样做有错,说是子句柄有错
    order_field_name(Index, 0)是排序字段变量名
      

  2.   

    如果是ado
    可以使用filter和sort等属性来完成
      

  3.   

    sql = "SELECT lngBaseInfoTypeID,BaseInfo.strBaseInfoCode from  BaseInfo where lngBaseInfoTypeID in (select lngBaseInfoTypeID 
    ,strBaseInfoCodefrom BaseInfo) Order By" + order_field_name(Index, 0)================================================================ok?
      

  4.   

    microsoft. jel 数据库引擎找不到输入表或查询"baseinfo",确定它是否存在或拼写是否有错
      

  5.   

    shawls(小山)(无业游民)(VB版的众矢之的) 
    能否说详细一点,我是个初学者!:)
      

  6.   

    如果数据库是SQL SERVER 的话,查询结果中再查询是没有问题的,如:
    select (select field_2 from usertabb003 where field_1=substring(t1.field_2,1,1)),count(*),sum(field_6) from  (select field_2 ,sum(field_6) as field_6 from usertabb005 where field_9<>'已收' group by field_2) t1
    group by substring(t1.field_2,1,1)
      

  7.   

    是access的,还且你那个太复杂了,我也看不太明白 :)
      

  8.   

    access 中应该是可以的,不过没有试过,简单的:
    select t1.* from (select field_1,field_2 from table1 ) t1 where t1.field_1='aa' order by field_1
      

  9.   

    select * from (select * from 表名) as 别名
      

  10.   

    谢谢各位了,我已经知道答案了
    sql="select * from ("+sql+") order by "+order_field_name(Index, 0)