This is a hybrid question & public service announcement. The basic question is whether there are convenient and/or efficient workarounds to the limitations listed below. I spent half the morning discovering that one cannot just transplant SQL code from Access to Matlab. I've boiled it down to 3 points so far.
The above limitations do not exist when submitting SQL code using the Access Query Designer (either in SQL 92 mode or not), nor do these limitations exist when submitting SQL code using VBA via CurrentProject.Connection.Execute.
Hopefully, this saves someone else some time in learning about these differences. And if anyone has found a workaround, that would be appreciated. Note that the above is in the context of using the JDBC/ODBC bridge (3rd of 3 illustrated configurations in the drivers documentation. The database toolbox documentation for directly connecting to an Access file using code (rather than setting up a data source using the GUI) only describes a code pattern that uses the JDBC/ODBC bridge. This is described in Example "Connect to Microsoft Access Using a File DSN" in the "Connect to database" page. I'd like to stick to this approach because I want to quickly be able to directly specify the source *.accdb file without jumping through GUI hoops of setting up a data source.
I've posted this to:
答案 0 :(得分:0)
虽然我没有将Matlab连接到Access,但我已将Access数据库连接到PHP,Python,SAS,R甚至Excel,而没有任何引号或星号问题。至于查询中所需的源表,仅仅是由于Jet / ACE SQL方言,因为每种方言都有其特定的规则。但是上面的查询应该适用于此类日期的单行,单列输出。 SQL Server不需要源表,但Oracle需要。访问日期采用MM/DD/YYYY
格式,条件语句中需要#
。 MySQL使用YYYY-MM-DD
格式的日期,需要单引号。
您使用的是Windows安装的Jet / ACE ODBC驱动程序吗?请注意,这些驱动程序是任何应用程序外部的软件(不属于Access),并且可以由任何连接到任何数据源的客户端使用。除此之外 - 许多人都不知道Access'后端数据库引擎,Jet / ACE实际上是一种Windows技术,不限于Access;没有安装Access的PC用户仍然可以使用此引擎。因此,connection strings是ODBC调用的标准。正如我所见,你可以将相同的原则应用于Matlab database connections。
据说,我的建议/解决方法:
chr(34)
进行双引号; chr(39)
单引号;星号chr(42)
。SELECT * INTO newtable FROM query
),然后连接到这个新表