gpt4 book ai didi

c# - sql query left join on mysql vs ms-access DB

转载 作者:行者123 更新时间:2023-11-29 00:43:29 25 4
gpt4 key购买 nike

这个查询

SELECT * 
FROM tblContracts
LEFT JOIN tblPartys ON tblContracts.id = tblPartys.Contract_id
INNER JOIN tblAdministrators
ON tblContracts.AdministratorID = tblAdministrators.ID

适用于 mysql 数据库,但不适用于 Access 数据库!!!

我遇到了这个错误:

System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'tblContracts.id = tblPartys.Contract_id INNER JOIN tblAdministrators ON tblContracts.AdministratorID = tblAdministrators.I'. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)

最佳答案

尝试在第一个连接周围添加一对括号

SELECT * 
FROM (tblContracts
LEFT JOIN tblPartys ON tblContracts.id = tblPartys.Contract_id)
INNER JOIN tblAdministrators
ON tblContracts.AdministratorID = tblAdministrators.ID

关于c# - sql query left join on mysql vs ms-access DB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11246638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com