I have two SQL tables Student and Class.
In Student table, the fields are studentNo, studentName, classNo
In Class table, fields are classNo, className, teacherName
what I am trying to do is construct a query to list all students who are in the history class.
Here is my query:
SELECT studentName
FROM Student s, Class c
WHERE s.classNo = c.classNo AND
c.className = ‘history’;
But I am not 100% sure about the above query. and I am thinking maybe the following one can work than the above one:
SELECT studentName
FROM Student s, Class c
WHERE c.className = ‘history’ AND
s.classNo = c.classNo;
Can anyone help me find the correct query to this problem? thank you
Your current query seems fine but mind if you convert it into
ANSI SQL_92format (more clear, and may not lead to cross join),There is no difference if you interchange the two. In math,
commutativelaw states thatA + B = B + A.