-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmp2.sql
67 lines (67 loc) · 2.73 KB
/
tmp2.sql
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
56
57
58
59
60
61
62
63
64
65
66
67
select *
from `users`
where (
exists (
select *
from
`applicants`
inner join `user_applicant_xrefs` on `applicants`.`id` = `user_applicant_xrefs`.`applicant_id`
where
`users`.`id` = `user_applicant_xrefs`.`user_id`
and exists (
select *
from
`users`
inner join `user_applicant_xrefs` on `user_applicant_xrefs`.`user_id` = `users`.`id`
where
`applicants`.`id` = `user_applicant_xrefs`.`applicant_id`
and exists (
select *
from `camp_org`
inner join `org_user` on `camp_org`.`id` = `org_user`.`org_id`
where
`users`.`id` = `org_user`.`user_id`
and `org_user`.`user_type` = 'App\Models\User'
and `camp_id` = 77
)
)
and `applicants`.`deleted_at` is null
)
or not exists (
select *
from
`applicants`
inner join `user_applicant_xrefs` on `applicants`.`id` = `user_applicant_xrefs`.`applicant_id`
where
`users`.`id` = `user_applicant_xrefs`.`user_id`
and exists (
select *
from
`users`
inner join `user_applicant_xrefs` on `user_applicant_xrefs`.`user_id` = `users`.`id`
where
`applicants`.`id` = `user_applicant_xrefs`.`applicant_id`
and exists (
select *
from `camp_org`
inner join `org_user` on `camp_org`.`id` = `org_user`.`org_id`
where
`users`.`id` = `org_user`.`user_id`
and `org_user`.`user_type` = 'App\Models\User'
and `camp_id` = 77
)
)
and `applicants`.`deleted_at` is null
)
)
and exists (
select *
from
`applicants`
inner join `user_applicant_xrefs` on `applicants`.`id` = `user_applicant_xrefs`.`applicant_id`
inner join `evcamp` on `applicants`.`id` = `evcamp`.`applicant_id`
where
`users`.`id` = `user_applicant_xrefs`.`user_id`
and `batch_id` in (167, 168)
and `applicants`.`deleted_at` is null
)