user3712823
user3712823

Reputation: 5

How can i do a Inner join with three tables?

I'm using inner join to merge two tables, but i want to add more one

$query = ("SELECT * FROM user A INNER JOIN applications B ON A.user_id = B.user_id  WHERE mark = 1 ");

I'm joining the user and the applications tables.

I want to call another table called templates, and call the ID_template.

how can i do that?

Upvotes: 0

Views: 56

Answers (1)

potashin
potashin

Reputation: 44601

The INNER JOIN syntax is the same for 2, 3 or n tables :

SELECT * 
FROM user A INNER JOIN applications B ON A.user_id = B.user_id  
            INNER JOIN templates T ON ?.? = T.?
WHERE mark = 1 

You should just add JOIN clause with the table you need and add ON clause with the joining condition.

Upvotes: 2

Related Questions