我有两张桌子。
购买:
PurchaseId
SenderId
ReceiverId
顾客:
Customerid
(主要-唯一)CUSID
(不是主要的-不是唯一的-允许为空)FirsName
LastName
我想在客户表中使用用户名和姓氏对所有购买进行一些报告。我无法建立任何关系。我所有的代码都给我错误或返回错误的结果。请帮助我。(接收者和发送者的值在客户表中是相等的 CUSID)关系是错误的:因为我不能创建任何主键,因为我的字段允许为空。
(select (tbl_Customers.FirstName + '-' + tbl_Customers.LastName) as receiver
FROM tbl_PurchaseForms
INNER JOIN
tbl_Customers ON tbl_PurchaseForms.ReceiverUId = tbl_Customers.CUSID)
or
(select (tbl_Customers.FirstName + '-' + tbl_Customers.LastName) as sender
FROM tbl_PurchaseForms
INNER JOIN
tbl_Customers ON tbl_PurchaseForms.SenderUId = tbl_Customers.CUSID)