I am trying to create a view that contains 2 joins for using a total of 3 tables. I keep getting: #1064 telling me I have a syntax error. However, I have been following what different guides and solutions say to do. Apparently, I am missing something.
I've done research on creating views for MySQL using joins and 3 tables, proper syntax of joins.
create view vw_interns_complete_training AS
select i.first_name, i.last_name, i.intern_id, inT.training_ID,
t.training, t.completed
from intern as i
inner join intern_training as inT on i.intern_ID = inT.intern_ID
inner join training as t On inT.training_ID = t.training_ID
where completed = 1;
The expected output is an successfully created join. The results are: "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'inT on i.intern_ID = inT.intern_ID inner join training as t On inT.training_ID' at line 4"
You should nou use a INT as table name alias INT (inT) is a reseved word
better change with inT with eg: it
create view vw_interns_complete_training AS
select i.first_name
, i.last_name
, i.intern_id
, it.training_ID
, t.training
, t.completed
from intern as i
inner join intern_training as it on i.intern_ID = it.intern_ID
inner join training as t On it.training_ID = t.training_ID
where t.completed = 1;