MS访问多个内部联接

时间:2018-05-24 02:15:50

标签: php sql ms-access

我有这个SQL查询

SELECT e.permission_name 
FROM ((((users_roles a 
          INNER JOIN users b 
          ON a.user_id = b.id) 
         INNER JOIN roles c 
         ON a.role_id = c.id) 
        INNER JOIN roles_permissions d 
        ON c.id = d.role_id) 
       INNER JOIN permissions e 
       ON d.permission_id = e.id) 
WHERE b.id = :id

我已经添加了括号,因为MS Access需要它,但它不起作用。

我在PHP中使用MS Access

1 个答案:

答案 0 :(得分:0)

我建议像这样编写查询:

  <div class="a-popover-wrapper">
    <div class="a-popover-header">
    <button class=" a-button-close a-declarative" aria-label="Close" data-action="a-popover-close">
    <i class="a-icon a-icon-close"/>
    </button>
    <h4 id="a-popover-header-7" class="a-popover-header-content">Buy professional installation</h4>
    </div>
    <div id="a-popover-content-7" class="a-popover-inner pdp-service-modal-instance" style="height: auto; overflow-y: auto;">
    </div>
    <span class="a-popover-end a-popover-a11y-offscreen" tabindex="0"/>
  </div>

与您的版本唯一真正的区别是对表别名使用SELECT p.permission_name FROM (((users_roles as ur INNER JOIN users as u ON ur.user_id = u.id ) INNER JOIN roles as r ON ur.role_id = r.id ) INNER JOIN roles_permissions as rp ON r.id = rp.role_id ) INNER JOIN permissions as p ON rp.permission_id = p.id WHERE u.id = :id;