主表:Maintables
主表ID       日期         布尔型
BillID     StockDate     IsAvail子表:Storage
主表ID     代码       布尔型
BillID     Code       Exist
主表:Shipment
主表ID            日期          布尔型
ShipmentID     ShipmentDate    IsAvail子表:Shipment_Detail
   主表ID      代码     布尔型
ShipmentID     Code     IsQuit
要求:用一个查询将Maintables和Shipment相同的时间段内的Code选择出来,且去除重复项,IsAvail、Exist、IsQuit为真

解决方案 »

  1.   

    用SQL套接!
    你最好先写个大概!
    别人在你的基础上修改比较好1
      

  2.   

    请先指明在什么数据库上?不同的数据库sql语法有差异的!
      

  3.   

    select code 
    from storage
    where Maintables.StockDate=Shipment.ShipmentDate and Maintables.billid=Storage.billid and
    union
    select code
    from Shipment_Detail
    where Maintables.StockDate=Shipment.ShipmentDate and
    Shipment.shipmentid=Shipment_Detail.shipmentid
      

  4.   

    多谢gamaster(a明),你的这个查询虽然不是我想得到的,但一些思路正是我想要的,问题解决了。给分!!