First, if you are learning SQL, you should be learning SQL correctly. Never use commas in the FROM clause. Always use proper, explicit, standard JOIN syntax.
So, your query should look like this:
SELECT S.status, S.city
FROM S JOIN
SP
ON SP.sNo = S.sNo
WHERE S.sNo = 'Paris' ;
Why does this return no results? Here are some reasons:
- No rows in
S and SP share the same city.
S.sNo never has the value 'Paris'.
- One or the other table has no rows (this is a subset of the first reason, but worth highlighting).
In this case, the most likely reason is the sNo never has the value 'Paris'. You have not provided any data, so I can only speculate that you intend:
SELECT S.status, S.city
FROM S JOIN
SP
ON SP.sNo = S.sNo
WHERE S.city = 'Paris' ;
But that would make sense.
One thing is suspicious. I would expect a key column called sNo to be numeric. In most databases, a comparison to a string (such as 'Paris') would return a type conversion error. MySQL does implicit conversion. So, if sNo is a number, then the comparison is interpreted as sNo = 0 -- and that could actually return rows if the condition were true.
INorEXISTSinstead of a join.