queryResult
tmpOrderQuntity
tblSetItem
我想要使用完全外部联接(带有左联接或右联接)的SqlLite中的链接拖表
我使用带有完全连接的MsSql服务器,它已经可以正确输出。但它不适用于Sql Lite
SQLLite此列值(CrStock-tmpOrderQuntity.OrderQuntuty)不正确父表(tblSetItem.CrStock)值为null,但子表(tmpOrderQuntity.OrderQuntuty)值正确
SELECT id,ItemCode,ItemDesc,imgPath,CrStock,CrUnitPrice,CrCostPrice,CrStock - tmpOrderQuntity.OrderQuntuty
AS 'AvailableQty',
0 AS 'ItemDiscount',Commission
FROM tblSetItem
LEFT JOIN tmpOrderQuntity ON tmpOrderQuntity.ItemID = tblSetItem.id
UNION
SELECT id,ItemCode,ItemDesc,imgPath,CrStock,CrUnitPrice,CrCostPrice,CrStock - tmpOrderQuntity.OrderQuntuty
AS 'AvailableQty',
0 AS 'ItemDiscount',Commission
FROM tmpOrderQuntity
LEFT JOIN tblSetItem ON tmpOrderQuntity.ItemID = tblSetItem.id
(表格:tblsetItem)
id ItemDesc ItemCode WarrentyPeriod Commission ModelID CreatedDate ModifiedDate Status UserID imgPath ShowInGallary CrUnitPrice IsCommAmount CrStock
1 Corless Drill Driver 14.4V (HDA5123L) test PRASA 5000 6 200 1 08:18.4 13:01.0 0 0 0 11813.05 0 1
2 Electric Drill 450W (HDA113) 5001 6 200 1 08:18.4 13:39.2 0 0 0 4217.4 0 12
3 Electric Drill 330W (HDA128) 5002 6 200 1 08:18.4 14:28.1 0 0 0 3782.61 0 22
4 Impact Drill 600W (HDA230) 5003 6 200 1 08:18.4 14:46.4 0 0 0 4739.14 0 2
(表格:tmpOrderQuntity)
ItemID OrderQuntuty
4 1.0
2 4.0
7 10.0
(查询结果Sql Lite)
id ItemCode ItemDesc imgPath CrStock CrUnitPrice CrCostPrice AvailableQty ItemDiscount Commission
1 5000 Corless Drill Driver 14.4V (HDA5123L) test PRASA 1 11813.05 0 null 0 200
2 5001 Electric Drill 450W (HDA113) 12 4217.4 0 8 0 200
3 5002 Electric Drill 330W (HDA128) 22 3782.61 0 null 0 200
4 5003 Impact Drill 600W (HDA230) 2 4739.14 0 1 0 200
5 5004 Rotary Hammer 710W (HDA316) 95 10860.87 0 null 0 200
6 5005 Rotary Hammer - 800W (HDA310) 58 10000 0 null 0 200+AA1:J7