Sunum yükleniyor. Lütfen bekleyiniz

Sunum yükleniyor. Lütfen bekleyiniz

SQL.

Benzer bir sunumlar


... konulu sunumlar: "SQL."— Sunum transkripti:

1 SQL

2 Sailors(sid: integer, sname: string, rating: integer, age: real)
Boats(bid: integer, bname: string, color: string) Reserves(sid: integer, bid: integer, day: dates)

3 Tum denizcilerin isimlerini ve yaslarini bulunuz
SELECT sname, age FROM Sailors

4 18 yasindan kucuk denizcilerin tum bilgilerini listeleyin
SELECT * FROM Sailors WHERE age < 18

5 103 numarali botu reserve eden denizcilerin isimlerini bulunuz
SELECT S.sname FROM sailors S, Reserves R WHERE S.sid = R.sid AND R.bid = 103

6 Kirmizi bot reserve eden denizcilerin sid’lerini bulunuz
SELECT R.sid FROM Reserves R, Boats B WHERE R.bid = B.bid AND B.color = ‘red’

7 Kirmizi bot reserve eden denizcilerin isimlerini bulunuz
SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid and B.color = ‘kirmizi’

8 Bob isimli denizci tarafindan reserve edilen botlarin renklerini bulunuz
SELECT B.color FROM Boats B, Reserves R, Sailors S WHERE B.bid = R.bid AND R.sid = S.sid AND S.sname = ‘Bob’

9 Ayni gun icinde iki farkli bot reserve eden denizcilerin isimlerini bulunuz
SELECT S.sname FROM Sailors S, Reserves R1, Reserves R2 WHERE S.sid = R1.sid AND R1.sid = R2.sid AND R1.day = R2.day AND R1.bid <> R2.bid

10 Kirmizi veya yesil bir bot reserve eden denizcilerin isimlerini bulunuz
SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid AND (B.color = ‘kirmizi’ OR B.color = ‘yesil’)

11 Hem kirmizi hem de yesil bot reserve eden denizcilerin isimlerini bulunuz
SELECT S.sname FROM Sailors S, Reserves R1, Reserves R2, Boats B1, Boats B2 WHERE S.sid = R1.sid AND S.sid = R2.sid AND R1.bid = B1.bid AND R2.bid = B2.bid AND B1.color = ‘kirmizi’ AND B2.color = ‘yesil’

12 UNION, INTERECT, EXCEPT, IN op ANY, op ALL EXIST
KUME ISLEMLERI

13 UNION – Kume Bilesimi Kirmizi ya da yesil bot reserve etmis denizcilerin isimlerini bulunuz
SELECT S.sname FROM Reserves R, Boats B, Sailors S WHERE R.bid= B.bid AND B.color = ‘kirmizi’ and R.sid = S.sid UNION WHERE R.bid= B.bid AND B.color = ‘yesil’ and R.sid = S.sid

14 INTERSECT– Kume Kesisimi Kirmizi ve yesil bot reserve etmis denizcilerin isimlerini bulunuz
SELECT S.sname FROM Reserves R, Boats B, Sailors S WHERE R.bid= B.bid AND B.color = ‘kirmizi’ and R.sid = S.sid INTERSECT WHERE R.bid= B.bid AND B.color = ‘yesil’ and R.sid = S.sid

15 EXCEPT: Kume farki Kirmizi bot reserve edip yesil bot reserve etmemis olan denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S, Boats B, Reserves R WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘kirmizi’ EXCEPT WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘yesil’

16 IN: Kumenin elemani 103 numarali botu reserve eden denizcilerin isimlerini bulunuz
SELECT S.sname FROM Sailors S WHERE S.sid IN (SELECT R.sid FROM Reserves R WHERE R.bid = 103) IC iCE girmis dongu

17 Hic kirmizi bot reserve etmemis denizcilerin isimlerini bulunuz
SELECT S.sname FROM Sailors S WHERE S.sid NOT IN (SELECT R.sid FROM Reserves R WHERE R.bid IN (SELECT B.bid FROM Boats B WHERE B.color = ‘kirmizi’))

18 op ANY: op herhangi birinden Derecesi Ali’nin derecesinden daha yuksek olan denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S WHERE S.rating > ANY(SELECT S2.rating FROM Sailors S2 WHERE S2.sname= ‘Ali’)

19 Derecesi en yuksek olan denizcinin ismini bulunuz
SELECT S.sname FROM Sailors S WHERE S.rating >= ALL (SELECT S2. rating FROM Sailors S2)

20


"SQL." indir ppt

Benzer bir sunumlar


Google Reklamları