Search code examples
sqlpostgresqlquoted-identifier

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

Solution

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