我有以下查询,它从三个表(PARTLIST,OPTIMIZATION_LIST,BATCH_LIST)中获取数据。
SELECT dbo.OPTIMIZATION_LIST.UPI_PARENT, dbo.OPTIMIZATION_LIST.UPI, dbo.OPTIMIZATION_LIST.MAIN_TYPE, dbo.PARTLIST.ORDERID, dbo.PARTLIST.ARTICLE_NAME, dbo.OPTIMIZATION_LIST.LENGTH,
dbo.OPTIMIZATION_LIST.WIDTH, dbo.OPTIMIZATION_LIST.THICKNESS, dbo.OPTIMIZATION_LIST.WEIGHT, dbo.OPTIMIZATION_LIST.CNT, dbo.OPTIMIZATION_LIST.CNT_INCR, dbo.OPTIMIZATION_LIST.SEQUENCE,
dbo.OPTIMIZATION_LIST.PART_LAYERS, dbo.OPTIMIZATION_LIST.PART_IN_LAYER, dbo.PARTLIST.INFO1, dbo.PARTLIST.INFO2, dbo.PARTLIST.INFO3, dbo.PARTLIST.INFO4, dbo.PARTLIST.INFO5, dbo.PARTLIST.INFO6,
dbo.PARTLIST.INFO7, dbo.PARTLIST.INFO8, dbo.PARTLIST.INFO9, dbo.PARTLIST.INFO10, dbo.PARTLIST.CUSTOMER, dbo.PARTLIST.BARCODE, dbo.BATCH_LIST.BATCHID_GROUP
FROM dbo.PARTLIST INNER JOIN
dbo.OPTIMIZATION_LIST ON dbo.PARTLIST.UPI = dbo.OPTIMIZATION_LIST.UPI INNER JOIN
dbo.BATCH_LIST ON dbo.OPTIMIZATION_LIST.BATCHID = dbo.BATCH_LIST.BATCHID
WHERE (dbo.OPTIMIZATION_LIST.MAIN_TYPE = 3) OR (dbo.OPTIMIZATION_LIST.MAIN_TYPE = 4)
我也想从OPTIMIZATION_LIST.UPI_PARENT that equals OPTIMIZATION_LIST.UPI
中获取该列,但是在表UPI
中没有针对该列的现有PARTLIST
,因为我仅将其收集在OPTIMIZATION_LIST
中。我尝试了OR (dbo.OPTIMIZATION_LIST.UPI = dbo.OPTIMIZATION_LIST.UPI_PARENT)
,但没有成功。有什么想法吗?