All pastes #286000 Raw Edit

Unnamed

public text v1 · immutable
#286000 ·published 2006-12-20 06:27 UTC
rendered paste body
1. select * from trgovec, oseba, mesto where trgovec.oid=oseba.oid and oseba.mid=mesto.mid and mesto.mid='M4';
2. select oseba.priimek from oseba, kupec, kupcija where oseba.oid=kupec.oid and kupec.kid=kupcija.kid and kupcija.tid='T2' and kupcija.aid='A5';
3. select artikel.barva from artikel, kupcija where kupcija.aid=artikel.aid and kid='K4'; (razporejeno po artiklih... A1 A2 A3 itd...) lahko pa damo tut distinct da sam barve dubimo vn.
4. select tid from kupcija where kid = K1 INTERSECT select tid from kupcija where kid = K2; **** mogoce bug u mysqlu...
5. select distinct artikel.aid from artikel, kupcija, kupec, oseba, mesto where artikel.aid=kupcija.aid and kupec.kid=kupcija.kid and kupec.oid=oseba.oid and mesto.mid=oseba.mid and oseba.mid=artikel.mid;
6. /
7. /
8. select distinct kupec.kid from kupec, artikel, kupcija, oseba, trgovec, mesto where artikel.aid=kupcija.aid and kupcija.kid=kupec.kid and kupcija.tid=trgovec.tid and trgovec.oid=oseba.oid and oseba.mid=mesto.mid and !(artikel.barva='Modra' and mesto.ime='Ankaran');
9. select distinct kupec.kid from kupec, kupcija where kupec.kid=kupcija.kid and !(kupcija.aid='A3' and kupcija.tid='T5');
10. select distinct kupec.kid from kupec, artikel, kupcija, oseba, trgovec, mesto where artikel.aid=kupcija.aid and kupcija.kid=kupec.kid and kupcija.tid=trgovec.tid and trgovec.oid=oseba.oid and oseba.mid=mesto.mid and !(artikel.barva='Modra' and mesto.ime='Ankaran');
11. -.
   + create index ena on oseba(mid);
   + create index dva on kupcija(tid, aid);
   + create index tri on kupcija(kid);
   + create index stiri on kupcija(kid, tid);
   + create index pet on atikel(mid);
   + create index pet on kupec(kid);
12. select aid from artikel where teza in (select min(teza) from artikel);
13. select oseba.priimek from trgovec, oseba, kupcija where trgovec.oid=oseba.oid and trgovec.tid=kupcija.tid group by oseba.priimek order by count(kosov) desc;
14. select count(*)  from kupcija where tid='T5';
15. select count(*)*2 from kupcija where aid='A5' and tid='T5'; (A5 je nogavica, T5 je adamic)
16. select oseba.priimek, sum(kosov) from trgovec, oseba, kupcija where trgovec.oid=oseba.oid and trgovec.tid=kupcija.tid group by oseba.priimek and sum(kosov) < 2000; ---- neki narobe s temle sum(kosov)
17. create view razdaljatabela as select distinct * from mesto, razdalja where mid1=mid union (select * from mesto, razdalja where mid2=mid) order by ime,mid1,mid2;
18. create index razdalje on razdaljatabela(mid, mid1, mid2);
19. /
20. /