以下SQL代码有什么问题:
INSERT INTO tbl_HAMP_Actions ( Loan_ID, Action_ID, Event_User, Event_Time, Event_Station, Reason_ID )
VALUES(3238, 3, 'CONTROL', Now(), 'CONTROL', (SELECT tbl_Reasons.Reason_ID
FROM tbl_Reasons
WHERE tbl_Reasons.Reason = 'Incorrect Information'));
答案 0 :(得分:0)
我认为您不能将子查询用作Access中的值。 试试这个:
INSERT INTO tbl_HAMP_Actions ( Loan_ID, Action_ID, Event_User, Event_Time, Event_Station, Reason_ID )
SELECT 3238, 3, 'CONTROL', Now(), 'CONTROL', Reason_ID
FROM tbl_Reasons
WHERE tbl_Reasons.Reason = 'Incorrect Information'
答案 1 :(得分:0)
(SELECT tbl_Reasons.Reason_ID
FROM tbl_Reasons
WHERE tbl_Reasons.Reason = 'Incorrect Information')
这部分代码可以返回多行吗?如果是这样,那么这将失败。
答案 2 :(得分:0)
我认为你可能会有一个看起来像这样的查询:
INSERT INTO tbl_HAMP_Actions
(
Loan_ID,
Action_ID,
Event_User,
Event_Time,
Event_Station,
Reason_ID
) VALUES (
3238,
3,
'CONTROL',
Now(),
'CONTROL',
DLookup("Reason_ID","tbl_Reasons","Reason = 'Incorrect Information'")
)