A database question encountered during the interview and a database encountered during the interview
I have interviewed many organizations over the past few days and made some pen-related questions. I will recall and sort them out.
The following is a list of problems
What impressed me today is a database operation question.
Question: There are three tables, which are required to query the eid and ename of all employees who [job development only]
At first, I felt very simple. I wrote the following SQL statement into it.
Select eid, ename from emp where eid not in (select eid from ej where jid = (select jid from job where jname = 'test '));
Later I thought it would be right, but what if there are three or more positions?
For example
The original statement is obviously not applicable.
Then I found another method.
Select eid, ename from emp where eid not in (select eid from ej where jid in (select jid from job where jname <> 'developing '));
The query result is correct! But...
I used two subqueries to reduce the efficiency of SQL statements. Is there a better way?
Here, I also hope to get your suggestions and see if there is a better answer!
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.