الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

استعلام صعب اوى بجمل الاس كيو العاديه

مغلق
بدأه isdep_makin في 18 مايو 2005 · 5 رد · 640 مشاهدة · في قواعد بيانات Microsoft SQL Server
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

قاعدة البيانات مكونه من 3 جداول وقد اجتهت لتوضحيها

واما السؤال فهو فى اخر المشاركه

sp table
sno mean supplier , pno mean parts
s1 p1 300    mean supplier s1 supplie the company with part p1 and thw qty =300

sno  pno  Qty         
---- ---- ----------- 
s1   p1   300
s1   p2   200
s1   p3   400
s1   p4   200
s1   p5   100
s1   p6   100
s2   p1   300
s2   p2   400
s3   p2   200
s4   p2   200
s4   p4   300
s4   p5   400

(12 row(s) affected)

in this table p1 no of the supplier , pname mean the name pf the part ,color mean the color of the part
city mean the place of the store which i take the parts from it
pno  pname      color      weight      city       
---- ---------- ---------- ----------- ---------- 
p1   nut        red        12          london    
p2   bolt       green      17          paris     
p3   screw      blue       17          oslo      
p4   screw      red        14          london    
p5   cam        blue       12          paris     
p6   cog        red        19          london    


(8 row(s) affected)

sno mean supplier number sname mean suppliername, city the place who live 

sno  sname      status      City       
---- ---------- ----------- ---------- 
s1   smith      20          london    
s2   jones      10          paris     
s3   blake      30          paris     
s4   clark      20          london    
s5   dams       30          athens    

(5 row(s) affected)

Question: 
write the query

get supplier numbers for suppliers who supply at least all those parts supplied by supplier s2

اريد الاجابه بجمل الالاس كيو الا وليس ال ترانس اكت

Mohamed Makeen

Senior Software Developer

Egypt - Cairo

eng_makin@hotmail.com

0142003269

#2

قبل أن نجيب على سؤالك:

1- ماهي محاولاتك؟

2- ماهي بنية الجداول؟

اقتباس
اريد الاجابه بجمل الالاس كيو الا وليس ال ترانس اكت

وهل هناك فرق بينهما؟ <_<

تم تعديل هذه المشاركة بواسطة walcom في 18 مايو 2005 في 18:50

فكر بطريقة أخرى

#3

ايه ياعم انت جايب المسألة من كتاب Date بتاع Introduction to Database

:D:D:D

Sr. Software Development Engineer
Hulu, LLC
My Blogs

#4

السلام عليكم

اخى الكريم wel com بالنسبه لمحاولاتى فهى ما قيل صلاة الظهر حتى صلاة المغرب ونقص 15 دقيقه غدا وانا كل التجارب اللى ملتها كانت على sql server واسف ليس هناك ما امتلكه منها

بالنسبه للفرق بين الsql والtansact لو كنت اعلم ما الفرق ما كنت حددت ( جاهل )

ممكن تقول لى الفرق وطبعا حد يكتب الquerey وياريت توضح معنى Exists لانى دماغى ورمت منها

ولا تقلق فلست ممنا يستسهلون ان يحل الاخرين المشاكل ( الامتحان يوم السبت ان شاء الله )

اخى bashohandes واضح انك شوفت كتاب date بصراحه اصبت الاختيار وانا عارف انك عرفت من الجداول :)

ارجو محاوله حل تلك المشكله سريعا

والسلام

Mohamed Makeen

Senior Software Developer

Egypt - Cairo

eng_makin@hotmail.com

0142003269

#5

السلام عليكم

هل تقصد نوع البيانات لو كان ذلك فها هو( نظر لضيق الوقت)

parts(pno char(2),pname char(10)),color char(10) weight int ,city char(10))
suppliers (sno char(2),sname char(10) status int , city char(10))
sp(sno char(2),pno char(2),qty int)

Mohamed Makeen

Senior Software Developer

Egypt - Cairo

eng_makin@hotmail.com

0142003269

#6

This is the Answer

/**                              Approach No.1                                          */ 
select * from sub y
where pno in (select pno from sub where sno='s2') --Get the parts of supplier No.2 and then asks who supplies it 
and y.sno<>'s2' --Exclude supplier No.2 from the result

/**                Approach No.2 ||Using Join Which Will Work on every database||       */ 
select  s.* from sub s inner join sub t
on (s.pno=t.pno) --join them on the part number
where t.sno='s2' --just the parts of supplier No.2
and s.sno<>'s2'  --Exclude supplier No.2 from the result

:rolleyes: :rolleyes: :rolleyes: :rolleyes: :rolleyes: :rolleyes: :rolleyes:

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…