database - Difference in two SQL query, but same result -
I'm new here, I think I'll get some help.
I have two questions
First
SELECT ename, deptno, sal, emp to emp WHERE sal (SELECT sal FROM emp WHERE deptno = 30) and COM IN (SELECT comm to emp WHERE deptno = 30)
SECOND
< Code> SELECT ename, deptno, sal, em em em (in serial, com) (select sal, com fam amp WHERE dept = 30)
they produce the same result , But what is the difference between them ???
Maybe the second result will back up faster than the first one .... or ???
Thank you very much!
These are not exactly the same questions. They can produce similar data, but that's because your dataset does not describe the difference.
As you can see, this: (your second query)
is not like this: (your first query)
Will also return the employee, of which 30 will get any salary, and the department will give the same commission to anyone in 30, but each of them is allowed for different people, i.e. wages a match w / person x Maybe and the commission can be a match w / person
your second query To any such employee will return the department less than the salary of an employee and commissions 30. But unlike the first inquiry, both pay and commission have to be a match for the same employee in the department 30, you can not make a match with one person and the other person with Y
In other words, your second query is more selective.
This is the reason why 'fish' is not included in my example data set, they have salaries that match 'Brian' (but no match / Brian commission), and They have a match w / doodle commission (but doodle has no salary). Because there is not a single match for any employee on the basis of both commissions and wages, so he is excluded.
He was included in other questions because one or the other had at least 1 / employee (but they were different people).
Performance-based, as a result of the questions given below, fewer tables will be scanned and can run faster, but you should only use it if it matches your intentions based on my statement Functional difference between the above 2 questions:
SELECT ename, deptno, sal, emp WHERE (sal, comm) from (select, emp WHERE deptno = 30 to com)
Comments
Post a Comment