بتاريخ: 27 ديسمبر 201015 سنة comment_206091 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 ديسمبر 201015 سنة comment_206105 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 تقديم بلاغ
بتاريخ: 27 ديسمبر 201015 سنة comment_206112 السلام عليكم ورحمة الله بالاضافة الى ما ذكرة الأخ / DR.Lavaيمكنك استخدام ال nvl للتعامل مع ال null value 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 ديسمبر 201015 سنة comment_206128 كل الكلام السابقى كلام سليم 100%ولكن الافضل والاصح واللى اوراكل نفسه بستعمله فى الابكليشن بتاعهاهو استخدام exist or no existوذلك فى الحقول التى يمكن ان تحتفظ بقيمة NULLبمعنى الكود يكون select employee.ename from emp employee where exist (selectmanager.mgr from emp manager where emp_no =selectmanager.mgr ) تقديم بلاغ
بتاريخ: 28 ديسمبر 201015 سنة كاتب الموضوع comment_206157 dr.lava, amgad ,صدقة جاريةشكرا جزيلا على ردودكم الاكثر من رائعة وبجد دة مش جديد على المنتدى الرائع بتاعنا تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.