error with inner join - table not found although it's there

716 Views Asked by At
SELECT * FROM "animalTbl" 
  INNER JOIN "deathTbl" 
  ON animalTbl.animalID = deathTbl.animalID;

this is my code, and when I run it shows a problem like this

 ERROR: missing FROM-clause entry for table "animaltbl"
LINE 3: ON animalTbl.animalID = deathTbl.animalID;
  ^
2

There are 2 best solutions below

0
On BEST ANSWER

Object names in postgres are generally case insensitive, but using double quotes to reference them forces case-sensitivity. Assuming the from clause is right, you should be consistent with your notations, and use the same notation in the on clause as you did in the from and join clauses:

SELECT     *
FROM       "animalTbl" 
INNER JOIN "deathTbl" ON "animalTbl".animalID = "deathTbl".animalID;
-- Here -----------------^---------^------------^--------^
0
On

You have to use the same case sensitive table name or aliases to qualify columns

Try this:

SELECT * FROM "animalTbl" a
  INNER JOIN "deathTbl" d
  ON a.animalID = d.animalID