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

Question

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

Answers 2
Added at 2017-01-05 16:01
Tags
Question
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;
  ^
Answers to

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

nr: #1 dodano: 2017-01-05 16:01

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
nr: #2 dodano: 2017-01-05 16:01

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 -----------------^---------^------------^--------^
Source Show
◀ Wstecz