Jure Sunic
Jure Sunic

Reputation: 3

#1066 - Not unique table/alias: 'EMP'

I am trying to create a query for my table but I get error. I have two tables in the database called 'assignment' and my two tables are 'emp' and 'dept'.

SELECT EMP.EMPNO, EMP.ENAME, EMP.SAL, DEPT.DNAME
FROM assignment.EMP, assignment.DEPT
INNER JOIN EMP on EMP.DEPTNO=DEPT.DEPTNO
WHERE EMP.SAL > 1000
AND DEPT.DNAME="SALES" LIMIT 0, 25
MySQL said: Documentation

#1066 - Not unique table/alias: 'EMP'

Upvotes: 0

Views: 41

Answers (1)

Chris Albert
Chris Albert

Reputation: 2507

Fixed your JOIN.

SELECT EMP.EMPNO, EMP.ENAME, EMP.SAL, DEPT.DNAME
FROM assignment.DEPT INNER JOIN assignment.EMP ON EMP.DEPTNO = DEPT.DEPTNO
WHERE EMP.SAL > 1000 AND DEPT.DNAME = "SALES" LIMIT 0, 25

Upvotes: 0

Related Questions