Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CREATE TABLE `Teste01` (
	`id_01`	INTEGER,
	`id_02`	INTEGER,
	PRIMARY KEY(`id_02`)
);


CREATE TABLE `Teste02` (
	`id_001`	INTEGER,
	`id_primary`	INTEGER,
	PRIMARY KEY(`id_primary`)
);


<pre>CREATE TABLE `Teste03` (
	`id_003`	INTEGER,
	`id_primary`	INTEGER,
	PRIMARY KEY(`id_primary`)
);


What I have tried:

select teste01.id_01, teste02.id_002, teste03.id_003 from teste01 inner join teste02 on teste01.id_01=teste02.id_primary; 


So, how I make a inner join with three tables?

Thanks.
Posted
Updated 30-Mar-17 8:41am
v2

1 solution

SQL
SELECT t1.[id_01]
     , t2.[id_002]
     , t3.[id_003]
  FROM [dbo].[Teste01] t1
    LEFT JOIN [dbo].[Teste02] t2 ON t2.[id_primary] = t1.[id_01]
    LEFT JOIN [dbo].[Teste03] t3 ON t3.[id_primary] = t1.[id_02];
 
Share this answer
 
Comments
MarkNopfler 30-Mar-17 13:58pm    
It´s didn´t work in my code.Would be beacause is Sqlite, I believe.
Thanks.
Michael_Davies 30-Mar-17 14:41pm    
Changed your tag to SQLite.

https://www.tutorialspoint.com/sqlite/sqlite_using_joins.htm
MarkNopfler 30-Mar-17 14:47pm    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900