如何对TQUERY控件的SELECT结果再进行第二次查询

解决方案 »

  1.   

    我通常是使用两个QUERY 第一个查询完之后保持打开状态 然后用第二个引用第一个建立的那张"临时表"去做二次查询
      

  2.   

    select * from a where a1(select * from a where ...)
      

  3.   

    刚才的错了!更正为:select * from a where a1 in (select * from a where ...)
      

  4.   

    select * from (select * from table where tid>1) as aaa where ....
      

  5.   

    你可以使用Filter属性或Locate方法,具体要看你需要的效果是什么样的
      

  6.   

    我用了3个TQUERY控件,前两个TQUERY控件是交叉表查询出结果,第三个TQUERY控件要SELECT前两个交叉表的结果。
    用select * from (select * from table where tid>1) as aaa where ....的话,(select * from table where tid>1)好象不能是交叉查询,必须要建立两个临时表。我的思路正确吗?还有更好的方法没呢?
      

  7.   

    用select * from (select * from table where tid>1) as aaa where ....的话,(select * from table where tid>1)好象不能是交叉查询,必须要建立两个临时表。谁说的?
    Select * from (
    Select a.ID, a.Name from (
    Select a.ID, b.Name from a Left join b on a.id = b.id 
    ) a
    ) b
      

  8.   

    我说的交叉查询是交叉表:
    TRANSFORM Sum(A.面积) AS 面积之总计
    SELECT B.分公司名称 AS 统计单位, A.验收树种 AS 树种, Sum(A.小班面积) AS 总面积
    FROM A INNER JOIN B ON A.编号 = B.编号
    GROUP BY B.分公司名称, A.验收树种
    PIVOT A.造林模式;
      

  9.   

    用过滤设置filter
    ' name='...
      

  10.   

    sql 自己就可以嵌套查询啊?
      

  11.   

    Select * from (SELECT B.分公司名称 AS 统计单位, A.验收树种 AS 树种, Sum(A.小班面积) AS 总面积
    FROM A INNER JOIN B ON A.编号 = B.编号
    GROUP BY B.分公司名称, A.验收树种) b
    where Conditions
      

  12.   

    ADOQuery有个filter属性,看一下帮助^_^
      

  13.   

    drop table a2
    creat table a2 as select * from a1 where id=456
    select * from a2 where id=456
      

  14.   

    select * from 表名 where 字段 in (select * from 表名B where ...)用SELECT的子查询就可以了
      

  15.   

    select * from a where a1(select * from a where ...)
      

  16.   

    用表变量或者临时表
    --表变量
    Declare @T table(a int,b int)
    insert into @t
    select a1 ,a2 from tablename where ...select * from @t where ...再或者直接在原先的sql上加条件限制
      

  17.   

    --临时表
    Create table #T
    ..//用法同表变量
      

  18.   

    照你的交叉查询的语法,你用的数据库是Access吗?如果是Access的话,好像没有什么好方法,最多看一下能不能通过建立Modules和Macro来实现存储过程的功能,最终能够拿到一个结果集如果是SQL Server的话,建议你用存储过程来实现
      

  19.   

    谢谢各位朋友~~~~~
    我用Grid++里面提供的方法做的交叉表,只要Select要的数据,再在报表里面处理成交叉表。
    再次感谢大家!~~~~~~~