日期:2014-05-17  浏览次数:21016 次

parent he fresh是什么意思
SQL code
SELECT PARENT.containername, 
      customer.customername,
      customer.description,
      FRESH.customerlotnumber,
      PARENT.qty,
      PARENT.targetdevice,
      con.containername as SubLot,
      con.qty as SubQty,
      con.customerlotnumber as SubCustLot,
      con.datecode as SubDateCode,
      tap.qtyperreel,
      FRESH.containername as FreshLot,
      product.customerspecificinfo2 as COO,
      con.customerorder,
      con.custmotherwo,
      pac.packagetypename,
      smd.shipmentdestinationname,
      dim.dimensionname,
      lea.leadcountname,
      pac.packagetypename || '-' || dim.dimensionname || '-' ||
      lea.leadcountname as PDL
  FROM insitedev.container          con,
      insitedev.container          PARENT,
      insitedev.customer            customer,
      insitedev.container          FRESH,
      insitedev.product            product,
      insitedev.tapenreelclass      tap,
      insitedev.packagetype        pac,
      insitedev.shipmentdestination smd,
      insitedev.dimension          dim,
      insitedev.leadcount          lea
WHERE ((con.parentcontainerid = PARENT.containerid) AND
      (PARENT.customerid = customer.customerid) AND
      (PARENT.freshlotid = FRESH.containerid) AND
      (PARENT.productid = product.productid) AND
      (product.tapenreelclassid = tap.tapenreelid) AND
      (product.packagetypeid = pac.packagetypeid) and
      (product.dimensionid = dim.dimensionid) AND
      (product.leadcountid = lea.leadcountid) and
      (fresh.shipmentdestinationid = smd.shipmentdestinationid) AND
      (PARENT.ContainerName like
      'TR7130017'))
ORDER BY con.qty ASC

其中为什么要用PARENT 和 FRESH,这两个函数有什么用,能详细讲解下么?
表的别名我知道

------解决方案--------------------
像这句(con.parentcontainerid = PARENT.containerid)
表示要找这张表里,这两个字段相同的纪录
如果你直接 
from insitedev.container
where
parentcontainerid=.containerid
这样结果只是找出同一行纪录中这两个字段相同的
比如你的纪录是这样
parentcontainerid containerid
1 2
2 1
你如果用 
select * 
from insitedev.container
where
parentcontainerid=containerid
出来结果是0 row


select a.parentcontainerid, b.containerid
from insitedev.container a,
insitedev.container b
where
a.parentcontainerid=b.containerid

出来结果是2row

parentcontainerid containerid
1 1
2 2