--employee (表1)
epyid    name      sex    dept   bz
001      aaa       b      sc     true
002      bbb       b      wl     false
003      ccc       g      sc     true--train  (表2)
trainid   content    date
t001      adfdasf    2004-01-01
t002      wereffer   2004-01-01
t003      werghdsg   2004-01-01--trainrec  (表3)
trainid   epyid   score  hours   
xxx       xxx     xx     xx
xxx       xxx     xx     xx
比如说要在表3中插入(尾随)参加过培训t001的人员(表1中bz为true)的记录,如何编程实现?给个思路?!
----------------------
应得到结果:
--trainrec  (表3)
trainid   epyid   score  hours  
xxx       xxx     xx     xx
xxx       xxx     xx     xx
t001      001     null   null
t001      003     null   null 
-------------------------------------------
补充一下,应该说是输入
目的是在几个dbedit中输入train的资料,
然后在dbgrid中选好参加train的人员(表1中作标记),
最后确定,且生成表3的记录(增添)

解决方案 »

  1.   

    用edit让客户填,填好用SQL对对应表插入记录.
      

  2.   

    hch_45(HCH ~ahong.net~)  没认真看清楚我的问题吧?
      

  3.   

    Insert into trainrec (trainid, epyid)
      Select t.trainid, e.epyid 
        From employee e, train t
       Where e.bz='true'
         And e.epyid = SubString(t.trainid,2,3)(注:自己査査子串函数)
      

  4.   

    insert into 表3 select  from 表1 where 条件
      

  5.   

    只用一条sql可以了吗? t001 和 001 只是编号没有联系的 。
    帮忙想想啊,
    还是,真的不行呢?
      

  6.   

    哦,想通了,揭帖表3加多个字段 bz
    Insert into trainrec (epyid,bz) 
    Select e.epyid,e.bz
        From employee e
        Where e.bz=true;
    update trainrec set trainid=培训编号 where bz=True;
    update trainrec set bz=false where bz=True;