Home > Database > Mysql Tutorial > body text

Access数据库多表连接查询

WBOY
Release: 2016-06-07 15:44:07
Original
1704 people have browsed it

第一次在Access中写多表查询,就按照MS数据库中的写法,结果报语法错,原来Access的多表连接查询是不一样的 表A、B、C,A关联B,B关联C,均用ID键关联 一般写法:select * from A inner join B on A.ID=B.ID inner join C on B.ID=C.ID 此写法在Access中报错

第一次在Access中写多表查询,就按照MS数据库中的写法,结果报语法错,原来Access的多表连接查询是不一样的

表A、B、C,A关联B,B关联C,均用ID键关联

一般写法:select * from A inner join B on A.ID=B.ID inner join C on B.ID=C.ID

此写法在Access中报错,Access对SQL语法理解方式不一样,它将两表连接后当作一个表然后再与第三个表连接,因此要改成

select * from (A inner join B on A.ID=B.ID ) inner join C on B.ID=C.ID

若出现第4张表D呢?

select * from ((A inner join B on A.ID=B.ID ) inner join C on B.ID=C.ID)  inner join D on C.ID=D.ID

……

可以理解为始终是两表间的操作

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template