“The table newspaper contains information about the newspaper subscribers. Count the number of subscribers who get a print newspaper.”
But how am I supposed to do this if I don’t know what tables exist? I have no reference for what columns to interact with. I have no idea how many columns there are.
Part of me wants to say my browser may not be loading this exercise correctly, or there is something I am missing, but I have tried to load this exercise on multiple browsers and multiple machines. The problem persists!
But that is my question. I had no way to know that there was a newspaper table, or an online table, or a months table. I could gather that there must be at least one table called newspaper, but there was no mention of an “online” table or a “months” table in the question.
It will raise an error but this is how to see what tables are present in the namespace…
SELECT *;
.> Error: near line 1: no tables specified
but it will show the schema for all the tables present.
Database Schema
newspaper60 rows
id INT
first_name VARCHAR(256)
last_name VARCHAR(256)
email VARCHAR(256)
start_month INT
end_month INT
online65 rows
id INT
first_name VARCHAR(256)
last_name VARCHAR(256)
email VARCHAR(256)
start_month INT
end_month INT
months12 rows
month INT
The instructions do tell us which tables to query, newspaper and online. We just need to take it on faith that the tables exist, but we’ve seen above how to query the full tables.
I don’t see mention of an “online” table in the instructions, but it does also raise another question: I am confused as to why this instruction requires a JOIN command at all. If it just wants the newspaper subscribers, and not the online ones, why am I joining the online user IDs with the newspaper user IDs? The logic doesn’t follow to me…
Right, but that would result in showing the subscribers with both online and printed newspapers correct? So if the exercise is designed to teach the student to use the JOIN statement, why does it ask for ONLY the newspaper subscribers? That would not require a JOIN statement that I can see…