Skip to main content

Hello, I would like to join two tables with the id as a key using the inner join, but when I try to do so, it doesn’t return any results even though it should return something. I woule like to know what is the correct syntaxis for this, I am using

 

SELECT * FROM "Table1" INNER JOIN "Table2" ON 'Table1.Table2_id' = 'Table2.id';

Thank you!

Try this without enclosing the table.


SELECT *
FROM Table1
INNER JOIN Table2 ON Table1.Table2_id = Table2.id;

 

What type of database are you using? Is it SQL Studio?


 


Hi thanks for your answer.

I am using PostgreSQL as database and the query doesn’t work if I don’t use the quotation marks, it doesn’t find the column names, and when I use it in quotes it retrieves the empty data table when it should have information inside of it.


Try this 
SELECT *
FROM "Table1"
INNER JOIN "Table2" ON "Table1"."Table2_id" = "Table2"."id";
 

 


Did it work?


Nope, it says that  "Table1"."Table2_id" does not exist, but the tables aren’t empty 


Can you message me your actual query?


SELECT *

FROM "People"

INNER JOIN "MasterPeople" ON “People”.”MasterPeople”_”idPerson” = “MasterPeople”.”idPerson”;


SELECT *
FROM "People"
INNER JOIN "MasterPeople" ON "People"."MasterPeople_idPerson" = "MasterPeople"."idPerson";
 


Try that

 


It is still the same 😞 The error says: “ERROR: column People.MasterPeople_idPerson does not exist”


Postgres is case-sensitive. Is the field names and table names identical?
SELECT *
FROM "People"
INNER JOIN "MasterPeople" ON "People"."MasterPeople_idPerson" = "MasterPeople"."idPerson";


Yes, the names are identical. As an example when I use just the select * and the name of the tables it works perfectly, the issue is with this inner join 


what about the field names?


Yes, everything is identical. I made sure of it several times


Can you give me a Select query with the fields of the table individually with *?

Bit challenging to know the issue without seeing the tables.


Reply