SQL Join Four Tables

57 Views Asked by At

I am trying to join 4 tables using sql. The tables are "Article" (Primary key "a_id", "title", "au_id", "i_id"), "Author" (Primary key "au_id", "name"), "Issue" (Primary key "i_id", "j_id", "number"), "Journal" (Primary key "j_id", "title").

I've tried INNER JOINS, JOIN with WHERE, disambiguing. Currently running code (in one line):

const sql = "SELECT a_id, Journal.title, Article.Title, Issue.Number, Author.Name 
FROM Article AS a 
INNER JOIN Author AS au ON a.au_id = au.au_id 
INNER JOIN Issue AS iss ON a.i_id = iss.i_id 
INNER JOIN Journal AS j ON iss.j_id = j.j_id";

I keep getting "no such column" when columns exists and have also been trying WC3 examples and tutorials without success.

1

There are 1 best solutions below

3
On

You have used FROM Article AS a so Article.Title does not exist. Use a.Title instead. Same is true for the other table aliases you have used