Daffa Akbari
Daffa Akbari

Reputation: 135

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

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;
  ^

Upvotes: 2

Views: 800

Answers (2)

Mureinik
Mureinik

Reputation: 311448

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 -----------------^---------^------------^--------^

Upvotes: 2

Gurwinder Singh
Gurwinder Singh

Reputation: 39487

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

Upvotes: 2

Related Questions