1+ SELECT DISTINCT
2+ site.* ,
3+ notes.* ,
4+ entity.* ,
5+ entity_link_reference.* ,
6+ reference.* ,
7+ depths.* ,
8+ dating.* ,
9+ dating_lamina.* ,
10+ sample.* ,
11+ hiatus.* ,
12+ ba_ca.* ,
13+ mg_ca.* ,
14+ p_ca.* ,
15+ sr_ca.* ,
16+ u_ca.* ,
17+ sr_isotopes.* ,
18+ d18o.* ,
19+ d13c.* ,
20+ original_chronology.* ,
21+ sisal_chronology.* ,
22+ compe.* ,
23+ composite_link_entity.* ,
24+ single_ent.*
25+ FROM
26+ site
27+ LEFT JOIN notes USING (site_id)
28+ LEFT JOIN entity USING (site_id)
29+ LEFT JOIN entity_link_reference ON entity .entity_id = entity_link_reference .entity_id
30+ LEFT JOIN reference USING (ref_id)
31+ LEFT JOIN (
32+ SELECT depth_dating AS depth, entity_id FROM dating
33+ UNION DISTINCT
34+ SELECT depth_lam AS depth, entity_id FROM dating_lamina
35+ UNION DISTINCT
36+ SELECT depth_sample AS depth, entity_id FROM sample
37+ ) AS depths ON depths .entity_id = entity .entity_id
38+ LEFT JOIN dating ON dating .entity_id = entity .entity_id AND dating .depth_dating = depths .depth
39+ LEFT JOIN dating_lamina ON dating_lamina .entity_id = entity .entity_id AND dating_lamina .depth_lam = depths .depth
40+ LEFT JOIN sample ON entity .entity_id = sample .entity_id AND sample .depth_sample = depths .depth
41+ LEFT JOIN hiatus USING (sample_id)
42+ LEFT JOIN ba_ca USING (sample_id)
43+ LEFT JOIN mg_ca USING (sample_id)
44+ LEFT JOIN p_ca USING (sample_id)
45+ LEFT JOIN sr_ca USING (sample_id)
46+ LEFT JOIN u_ca USING (sample_id)
47+ LEFT JOIN sr_isotopes USING (sample_id)
48+ LEFT JOIN d18o USING (sample_id)
49+ LEFT JOIN d13c USING (sample_id)
50+ LEFT JOIN original_chronology USING (sample_id)
51+ LEFT JOIN sisal_chronology USING (sample_id)
52+ LEFT JOIN entity compe ON entity .entity_id = compe .entity_id
53+ LEFT JOIN composite_link_entity ON compe .entity_id = composite_entity_id
54+ LEFT JOIN entity single_ent ON composite_link_entity .single_entity_id = single_ent .entity_id
55+ WHERE site .site_id = 316
56+ ORDER BY entity .entity_id , depths .depth ;
0 commit comments