-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueryes.sql
More file actions
55 lines (36 loc) · 3.65 KB
/
queryes.sql
File metadata and controls
55 lines (36 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
select * from tabsoggetto join tabresidenze on tabsoggetto.idSoggetto=tabresidenze.rif_soggetto;
select * from tabistanza join tabsoggetto on tabistanza.id_sponsor=tabsoggetto.idSoggetto;
select * from tabsoggettiistanze
join tabsoggetto on tabsoggettiistanze.rif_soggetto=tabsoggetto.idSoggetto
join tabistanza on tabsoggettiistanze.rif_istanza=tabistanza.idIstanza;
select * from tabnucleifull
join tabsoggetto on tabnucleifull.rif_soggetto=tabsoggetto.idSoggetto
join tabistanza on tabnucleifull.rif_istanza=tabistanza.idIstanza;
select tabmandato.* from tabmandato
join tabnucleifull on tabmandato.rif_nucleofull=tabnucleifull.id
join tabsoggetto on tabmandato.rif_sponsor=tabsoggetto.idSoggetto;
select * from tabMandatoPVC
join tabnucleifull on tabMandatoPVC.rifNucleoFull=tabnucleifull.id
join tabsoggetto on tabMandatoPVC.rifSponsor=tabsoggetto.idSoggetto;
-- attenzione il bonifico contiene la cifra unica di entrambi
select idSoggetto from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H');
delete from tabresidenze where rif_soggetto in (select idSoggetto from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H'));
delete from tabistanza where id_sponsor in (select idSoggetto from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H'));
delete from tabsoggettiistanze where rif_soggetto in (select idSoggetto from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H'));
delete from tabnucleifull where rif_soggetto in (select idSoggetto from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H'));
delete from tabmandato where rif_sponsor in (select idSoggetto from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H'));;
delete from tabMandatoPVC where rifSponsor in (select idSoggetto from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H'));;
delete from tabsoggetto where codiceFiscale in ('GDFGMN70D16H501T','GDLGMN70D16H501R','GDLGMN70D18H501F','GDLGMN70D18H501H','GDFGMN70D16H501R','GDFGMN70D18H501F','GDFGMN70D18H501H');
-- recupero dell'ultima istanza nucleo principale (1 iniziale, 3 modificata)
select idIstanza from tabistanza
where id_sponsor=(select idSoggetto from tabsoggetto where codiceFiscale='GDFGMN70D16H501T') and rif_tipoIstanza in (1, 3) ORDER BY idIstanza DESC LIMIT 1;
-- recupero dell'ultima istanza nucleo esterno (4 iniziale, 5 modificata)
select idIstanza from tabistanza
where id_sponsor=(select idSoggetto from tabsoggetto where codiceFiscale='GDFGMN70D16H501T') and rif_tipoIstanza in (4, 5) ORDER BY idIstanza DESC LIMIT 1;
-- recupero dei facenti parte il nucleo principale
select * from tabnucleifull where rif_istanza = 42;
-- recupero dei facenti parte il nucleo esterno
select * from tabnucleifull where rif_istanza = 47;
select * from tabcartaesercito
join tabnucleifull on tabcartaesercito.rif_soggetto = tabnucleifull.rif_soggetto
where tabnucleifull.rif_istanza = 42