-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_example.sql
33 lines (31 loc) · 1.07 KB
/
query_example.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
/*
This is an example query on where/how to use joins in this database
Ty Garber 4/28/2023
*/
select
rec.*,
lstock.name as stock_name,
lrec.name as recovery_location,
lrel.name as hatchery
from
releases rel
left join recoveries rec on rel.tag_code_or_release_id = rec.tag_code
left join locations lrec on rec.recovery_location_code = lrec.location_code and
lrec.location_type = '1'
left join locations lrel on rel.hatchery_location_code = lrel.location_code and
lrel.location_type = '3'
left join locations lstock on rel.stock_location_code = lstock.location_code and
lstock.location_type = '5'
where
rel.tag_code_or_release_id in ('634281',
'634844',
'635292',
'635282',
'636168',
'636299',
'636669',
'636824',
'636954',
'637171',
'637227',
'637350');