تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
EXISTS Operator
#1
كاتب الموضوع : AhmedEssawy

الاستعلام ان الموظفين الموجودين في جدول الموظفين و غير موجودين في جدول job


كود :
[color=#990000]1[/color][color=black]>[/color][FONT=Courier New]
[color=#990000]2[/color][color=black]>[/color]
[color=#990000]3[/color]> select * from [color=black]employee;[/color]
[color=#990000]4[/color][color=black]> GO[/color]
[color=black]ID name salary[/color]
[color=black]----------- ---------- -----------[/color]
[color=#990000]1 [/color][color=black]Jason [/color][color=#990000]1234[/color]
[color=#990000]2 [/color][color=black]Robert [/color][color=#990000]4321[/color]
[color=#990000]3 [/color][color=black]Celia [/color][color=#990000]5432[/color]
[color=#990000]4 [/color][color=black]Linda [/color][color=#990000]3456[/color]
[color=#990000]5 [/color][color=black]David [/color][color=#990000]7654[/color]
[color=#990000]6 [/color][color=black]James [/color][color=#990000]4567[/color]
[color=#990000]7 [/color][color=black]Alison [/color][color=#990000]8744[/color]
[color=#990000]8 [/color][color=black]Chris [/color][color=#990000]9875[/color]
[color=#990000]9 [/color][color=black]Mary [/color][color=#990000]2345[/color]

[color=black]([/color][color=#990000]9 [/color][color=black]rows affected)[/color]
[color=#990000]1[/color]> select * from [color=black]job;[/color]
[color=#990000]2[/color][color=black]> GO[/color]
[color=black]ID title averageSalary[/color]
[color=black]----------- ---------- -------------[/color]
[color=#990000]1 [/color][color=black]Developer [/color][color=#990000]3000[/color]
[color=#990000]2 [/color][color=black]Tester [/color][color=#990000]4000[/color]
[color=#990000]3 [/color][color=black]Designer [/color][color=#990000]5000[/color]
[color=#990000]4 [/color][color=black]Programmer [/color][color=#990000]6000[/color]

[color=black]([/color][color=#990000]4 [/color][color=black]rows affected)[/color]
[color=#990000]1[/color][color=black]>[/color]
[color=#990000]2[/color][color=black]>[/color]
[color=#990000]3[/color][color=black]> -- The EXISTS Operator[/color]
[color=#990000]4[/color][color=black]>[/color]
[color=#990000]5[/color]> SELECT [color=black]ID, Name[/color]
[color=#990000]6[/color]> FROM [color=black]Employee e[/color]
[color=#990000]7[/color]> WHERE [color=black]NOT EXISTS[/color]
[color=#990000]8[/color]> (SELECT [color=black]ID[/color]
[color=#990000]9[/color]> FROM [color=black]job j[/color]
[color=#990000]10[/color]> WHERE [color=black]j.ID = e.ID)[/color]
[color=#990000]11[/color][color=black]> GO[/color]
[color=black]ID Name[/color]
[color=black]----------- ----------[/color]
[color=#990000]5 [/color][color=black]David[/color]
[color=#990000]6 [/color][color=black]James[/color]
[color=#990000]7 [/color][color=black]Alison[/color]
[color=#990000]8 [/color][color=black]Chris[/color]
[color=#990000]9 [/color][color=black]Mary[/color]

[color=black]([/color][color=#990000]5 [/color][color=black]rows affected)[/color][/FONT]
}}}}
تم الشكر بواسطة:


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم