![]() |
Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Basi di dati ~ comunicazione digitale (http://www.dsy.it/forum/forumdisplay.php?forumid=108)
-- dubbio sql (http://www.dsy.it/forum/showthread.php?threadid=38689)
dubbio sql
qlc sa dirmi se questa interrogazione :
code:
select Docente, count(*) from Corso, Lezione, Periodo where Corso.CodC=Lezione.CodC and Lezione.CodP=Corso.CodP and (Giorno=’Lunedì’ or Giorno=’Martedì’) and Aula=’Alfa’ group by Docente having count (distinct Corso.CodC)=2;
code:
select Docente, count(*) from Corso natural join Lezione natural join Periodo where (Giorno=’Lunedì’ or Giorno=’Martedì’) and Aula=’Alfa’ group by Docente having count (distinct Corso.CodC)=2;
Se ricordo bene gli schemi delle relazioni Corso, Lezione e Periodo sì: è lo stesso.
In generale devi solo assicurarti che non vi siano attributi omonimi oltre ai riferimenti (in questo caso CodC e CodP) che legano le relazioni.
questo e' lo schema
code:
Corso(CodC, Nomenn, Docentenn) Lezione(CodC fk->Corso.CodC, CodP fk->Periodo.CodP,Aulann,Edificionn) Periodo(CodP, Giornonn, OraInn)
Sì, confermo.
Il natural join realizza esattamente la stessa operazione.
| All times are GMT. The time now is 03:13. | Show all 4 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.