我有一个SQL查询,我使用向导创建,然后修改了一下。此查询需要从同一工作簿中的两个工作表中提取数据。以下是我稍加修改的代码:
SELECT `'TA Submissions$'`.`TA Content`, `'TA Submissions$'`.`Subject of TA`, `'TA Submissions$'`.`Unit of TA`, `'TA Submissions$'`.`Title of TA`, `'TA Submissions$'`.`Any Notes for the Invigilator or student?`, `TAs$`.`Group Code`, `TAs$`.`TA Code`, `TAs$`.`Extra Time`, `TAs$`.Student, `TAs$`.Subject, `TAs$`.Teacher, `TAs$`.Day, `TAs$`.Start, `TAs$`.Finish, `TAs$`.Duration, `TAs$`.`TA Subject`
FROM `'TA Submissions$'` `'TA Submissions$'`, `TAs$` `TAs$`
WHERE `TAs$`.Teacher+` - `+`TAs$`.`TA Subject` = `'TA Submissions$'`.`Teacher Name & Class Group` AND ((`TAs$`.`Submitted?`='Yes')) AND ((`TAs$`.`Generated?`<>'Generated'))
我通常不使用SQL,所以任何人都可以指出我正确的方向!我只发现线程从Access到Excel而不是Excel到Excel。
非常感谢。
答案 0 :(得分:0)
在大多数SQL方言中,要连接字段,您可以使用&符号&
,而加号(+
)表示加法运算符,连字符(-
)表示减法运算符。
在WHERE
子句中考虑以下调整:
SELECT `'TA Submissions$'`.`TA Content`, `'TA Submissions$'`.`Subject of TA`,
`'TA Submissions$'`.`Unit of TA`, `'TA Submissions$'`.`Title of TA`,
`'TA Submissions$'`.`Any Notes for the Invigilator or student?`,
`TAs$`.`Group Code`, `TAs$`.`TA Code`, `TAs$`.`Extra Time`,
`TAs$`.Student, `TAs$`.Subject, `TAs$`.Teacher,
`TAs$`.Day, `TAs$`.Start, `TAs$`.Finish, `TAs$`.Duration, `TAs$`.`TA Subject`
FROM `'TA Submissions$'` `'TA Submissions$'`, `TAs$` `TAs$`
WHERE `TAs$`.Teacher & `TAs$`.`TA Subject` =
`'TA Submissions$'`.`Teacher Name & Class Group`
AND ((`TAs$`.`Submitted?`='Yes')) AND ((`TAs$`.`Generated?`<>'Generated'))