我正在尝试使用外键连接多个表,以便能够访问其他列。我有下面的查询,这个结果显示了一个包含重复数据的表
目前的结果
+-----------+-----------+----------+----------+-------------+-------------+-----+
| ponumber | drNumber | itemCode | itemName | receivedQty | rejectedQty | ... |
+-----------+-----------+----------+----------+-------------+-------------+-----+
| 00000001 | 000000002 | 13333333 | button | 1 | 0 | |
| 00000001 | 000000002 | 13333333 | button | 20 | 0 | |
+-----------+-----------+----------+----------+-------------+-------------+-----+
预期结果
+-----------+-----------+----------+----------+-------------+-------------+-----+
| ponumber | drNumber | itemCode | itemName | receivedQty | rejectedQty | ... |
+-----------+-----------+----------+----------+-------------+-------------+-----+
| 00000001 | 000000002 | 13333333 | button | 1 | 0 | |
| 00000001 | 000000002 | 13333331 | pajama | 20 | 0 | |
+-----------+-----------+----------+----------+-------------+-------------+-----+
看起来查询正在获取所需的信息,即2行,但结果不正确。
SELECT SPO.poNumber
,SDR.drNumber
,I.itemCode
,I.itemName
,SDR.receivedQty
,SDR.rejectedQty
,SPO.volumeQty
,SPO.dateMade
,SPO.deliveryDate
,U.lastName AS preparedbyLastName
,U.firstName AS preparedbyFirstName
,S.unitPrice
,I.unitMeasurement
,I.inventoryType
,SPO.receivingStatus
,SPO.notes
FROM ref_item I
JOIN ref_supplier S ON S.itemCode = I.itemCode
JOIN supplier_purchase_order SPO ON SPO.supplier = S.supplierID
JOIN supplier_delivery_receipt SDR ON SDR.poNumber = SPO.poNumber
JOIN user U ON SPO.preparedBy = U.employeeID
WHERE SPO.poNumber = 70000006
AND SPO.receivingStatus != "complete"
ORDER BY itemName;
受影响的表是ref_item,ref_supplier,supplier_purchase_order和supplier_delivery_receipt
答案 0 :(得分:0)
您必须按表示为主键的所有列链接您的表,并将其链接到其他表作为外键。
例如,您的表格var myApp = angular.module('myApp',[]);
myApp.directive('dSec', function($window) {
return {
link: function(scope, elm, attr, ctrl) {
scope.initialScroll[attr.id] = elm.prop('offsetTop');
angular.element($window).bind("scroll", function() {
if (this.pageYOffset >= scope.initialScroll[attr.id]
&& !scope.hitScroll[attr.id]) {
console.log("Scroll to --> ", attr.id);
scope.hitScroll[attr.id] = true;
}
});
}
};
});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.initialScroll = {};
$scope.hitScroll = {};
}
和表格supplier_purchase_order
与列supplier_delivery_receipt
和poNumber
相关联,但在您的查询中,您只有1列
itemCode
您需要在每个联接中放置两列。要获得有关如何解决此检查的更多信息this link。
希望它可以帮到你
答案 1 :(得分:0)
您需要使用img src="images/headerimagename.png"
和ON
加入所有主要加密键。
AND