#1066 - 不是唯一的表/别名:'tb_X' [英] #1066 - Not unique table/alias: 'tb_X'

查看:37
本文介绍了#1066 - 不是唯一的表/别名:'tb_X'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试加入 3 个表时遇到问题.

I got a problem when I was trying to join 3 tables.

以下是我使用的 mysql 语法:

Below are the mysql syntax i was using :

SELECT
FROM carecell
LEFT JOIN staff ON cc.id_pks = staff.id_emp
LEFT JOIN staff ON cc.id_wpks = staff.id_emp
INNER JOIN member ON member.id_member = staff.id_member

请帮助我.. 我应该怎么做才能修复语法?

Please Help me.. What should I do in order to fix the syntax?

推荐答案

SQL 引擎无法区分 from 子句中的两个 staff 表.你需要给他们不同的名字.像这样:

The SQL engine cannot distinguish between the two staff tables in the from clause. You need to give them different names. Something like this:

FROM carecell cc LEFT JOIN
     staff s1
     ON cc.id_pks = s1.id_emp LEFT JOIN
     staff s2
     ON cc.id_wpks = s2 .id_emp INNER JOIN
     member m
     ON m.id_member = s2.id_member

这篇关于#1066 - 不是唯一的表/别名:'tb_X'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆