⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Connection between the three tables



pcheliakov
  • profile picture
  • Member

Posted 18 January 2014 - 19:50 PM

Hello. There are 3 tables. The first Students id_student, name), the second "Universities" (id_university, title). And a third table relative LINK (id_student, id_university, release_year). How can I write code to link? Here is the SQL query that should be
SELECT s.name, u.title, l.release_year FROM `students` AS `s`
		INNER JOIN `link` As `l` On l.student_id = s.student_id
		INNER JOIN `universities` As `u` On u.university_id = l.university_id

ssfthurber
  • profile picture
  • Member

Posted 18 February 2014 - 18:51 PM

 

Hello. There are 3 tables. The first Students id_student, name), the second "Universities" (id_university, title). And a third table relative LINK (id_student, id_university, release_year). How can I write code to link? Here is the SQL query that should be
SELECT s.name, u.title, l.release_year FROM `students` AS `s`
		INNER JOIN `link` As `l` On l.student_id = s.student_id
		INNER JOIN `universities` As `u` On u.university_id = l.university_id

the sql code can be put in a view then use the view name instead of a table name