I am a complete beginner in SQL. I am using a program that queries a database, and then processes the results. The default query is:
SELECT *
FROM data,
questions,
users
where users.U_Id = data.Subj_Id
and data.Subj_Id between 1 and 10
and data.Q_Id = questions.Q_Id
and questions.Q_Id between 1 and 10
order by Subj_Id;
I’d like it to query every Subj_Id and every Q_Id. I do not know how many there are of either, and different subjects have different numbers of questions. How should I alter the above query?
You can rewrite the above query like this.
This makes it clearer by separating the joins between tables from the filters on the data.
So to query the entire database, you just remove the
whereclause from the above…