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 want to display article title, author, journal and issue. Atm it only displays author and issue. However the data seems to be in the row, just not showing. Current code:
const sql = "SELECT a.a_id, a.title, j.title, iss.number, au.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";
Ensure your data is properly structured to deliver the result you want