内部联接行不受影响

时间:2016-01-02 10:22:47

标签: mysql

当我尝试使用此代码在我的表salesfacts中插入数据时,它表示0行会受到影响,但是当我删除插入时,只执行select,它会显示我的salesfacts表。任何人都可以帮我解决这个问题。

truncate table SalesFacts

INSERT INTO Assignment1SS..SalesFacts
(ProductCode, CustomerNumber, EmployeeNumber, officeCode, buyPrice, MSRP, quantityOrdered) 

SELECT 

p.ProductCode, 
c.CustomerNumber, 
e.EmployeeNumber, 
y.officeCode, 
p.buyPrice, 
p.MSRP, 
od.quantityOrdered

FROM
Assignemnt1..[OrderDetails] od INNER JOIN Assignemnt1..[Orders] o
ON od.orderNumber = o.orderNumber

INNER JOIN Assignment1SS..[ProductSS] p 
ON od.productCode = p.productCode

INNER JOIN Assignment1SS..[CustomersSS] c
ON od.OrderNumber = c.CustomerNumber

INNER JOIN Assignment1SS..[EmployeeSS] e
ON c.SalesRepEmployeeNumber = e.EmployeeNumber

INNER JOIN

(select e.[EmployeeNumber], y.[officeCode]
from Assignemnt1..[Employees] e
inner join Assignemnt1..[Offices] y
on e.officeCode = y.officeCode
group by e.[EmployeeNumber],y.[officeCode]) y

on c.salesRepEmployeeNumber = y.EmployeeNumber 

CustomersSS表

    Create Table CustomersSS (
CustomerNumber int NOT NULL,
CustomerName varchar (50) NOT NULL,
ContactLastName varchar (50) NOT NULL,
ContactFirstName varchar (50) NOT NULL,
Phone varchar (50) NOT NULL,
AddressLine1 varchar (50) NOT NULL,
AddressLine2 varchar (50) NULL,
City varchar (50) NOT NULL,
State varchar (50) NULL,
PostalCode varchar (15) NULL,
Country varchar (50) NOT NULL,
SalesRepEmployeeNumber int NULL,
CreditLimit money NOT NULL,
PRIMARY KEY (CustomerNumber));

1 个答案:

答案 0 :(得分:0)

您的查询有误,请使用以下查询。

curl_multi_add_handle($mh,[$ch1,$ch2]); ??