select employee.ename from emp employee where employee.empno not in (select manager.mgr from emp manager )على الرغم ان الكود هذا يعطى نتيجة
select employee.ename from emp employee where employee.empno in (select manager.mgr from emp manager )
تاريخ المشاركة 27 December 2010 - 09:04 PM
Because all emp_id's are not in nothing
The above SQL statement attempts to display all the employees who do not have any subordinates. Logically, this SQL statement should have returned eight rows. However, the SQL statement does not return any rows. One of the values returned by the inner query is a null value and hence the entire query returns no rows. The reason is that all conditions that compare a null value result in a null. So whenever null values are likely to be part of the resultant set of a subquery, do not use the NOT IN operator. The NOT IN operator is equivalent to !=ALL.
Notice that the null value as part of the resultant set of a subquery will not be a problem if you are using the IN operator. The IN operator is equivalent to =ANY
Research & Development Manager
تاريخ المشاركة 28 December 2010 - 12:17 AM
SQL> select employee.ename 2 from emp employee 3 where employee.empno not in 4 (select nvl(manager.mgr,0) from emp manager ) 5 / ENAME ---------- SMITH ALLEN WARD MARTIN TURNER ADAMS JAMES MILLER 8 rows selected.
لا إله إلا الله الحليم الكريم
لا اله إلا الله العلى العظيم
لا اله إلا الله رب السماوات السبع و رب العرش العظيم
اللهم ارزقني قبل الموت توبة وعند الموت شهادة وبعد الموت جنة
اللهم ارزقني حسن الخاتمة
اللهم هون علينا سكرات الموت ... ونور علينا قبورنا
اللهم ارزقني الموت وأنا ساجد لك يا ارحم الراحمين
اللهم ثبتني عند سؤال الملكين
اللهم اجعل قبري روضة من رياض الجنة ولا تجعله حفرة من حفر النار
اللهم اني اعوذ بك من فتن الدنيا
اللهم ارحم ابائنا وامهاتنا واغفر لهما وتجاوز عن سيئاتهما وادخلهم فسيح جناتك ... والحقنا بهما يا رب العالمين
اللهم ارحم موتانا وموتى المسلمين واشفي مرضانا ومرضى المسلمين
اللهم اغفر للمسلمين والمسلمات والمؤمنين والمؤمنات الأحياء منهم والأموات
وبارك اللهم على سيدنا محمد صلى الله عليه وسلم
اللهم آمين ... اللهم آمين ... اللهم آمين
....
تاريخ المشاركة 28 December 2010 - 06:34 AM
select employee.ename from emp employee where exist (selectmanager.mgr from emp manager where emp_no =selectmanager.mgr )