select * from TB_Data_1_5 where Picname  in ( select picname from TB_Picture where batchname='+Quotedstr(CurrBatchName)+' and User5='+QuotedStr(TLoginUser.Instance.UserID)+' ) and  batchname='+Quotedstr(CurrBatchName);

解决方案 »

  1.   

    小MM建议你看看Sql语句的相关书籍先,每一句都问只是解决当前问题。
    这句的意思是在TB_Data_1_5查询,条件是Picname  必须在后边select查询的数据之中。
      

  2.   

    select picname from TB_Picture where batchname='+Quotedstr(CurrBatchName)+' and User5='+QuotedStr(TLoginUser.Instance.UserID)+' 这个查询返回一个含有picname字段的结果集合,
    相当于select * from TB_Data_1_5 where Picname  in ('张三','李四','王五')
      

  3.   

    哈哈。我不看。就问你们得了!!还有我不是MM,我是GG!
      

  4.   

    select * from TB_Data_1_5 where Picname  in ( select picname from TB_Picture where batchname='+Quotedstr(CurrBatchName)+' and User5='+QuotedStr(TLoginUser.Instance.UserID)+' ) and  batchname='+Quotedstr(CurrBatchName);这样子写,要是有问题,很难找啊,还是好好的格式化一下。
      

  5.   

    书上讲的很清楚了;只要你看一下SQL方面的书;
      

  6.   

    这是SQL语名中SELECT中基本的用法之一,真的得好好学下SQL了~:)