meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| pluginto:useful_sql_queries [2026/01/21 16:48] – joetulenko | pluginto:useful_sql_queries [2026/01/21 17:21] (current) – joetulenko | ||
|---|---|---|---|
| Line 308: | Line 308: | ||
| \\ | \\ | ||
| + | |||
| + | 9. LEFT JOIN - let's say I want info on a bunch of samples from multiple fields/ | ||
| + | |||
| + | In the example below, I am searching for sample names, sample 10Be (and/or 26Al) concentrations, | ||
| + | |||
| + | (1) samples that only have 10Be concentrations (and/or 26Al concentrations) \\ | ||
| + | (2) samples that only have 14C concentrations \\ | ||
| + | (3) samples that have both 10Be (and/or 26Al concentrations) AND 14C concentrations \\ | ||
| + | (4) samples have none of the above - likely because a sample is linked to an incomplete entry in either the 10Be/26Al table and/or the 14C table that's missing nuclide concentration(s) \\ | ||
| + | |||
| + | (using a standard JOIN would only select samples that satisfy criteria 3 and in rare cases 4) | ||
| + | |||
| + | < | ||
| + | |||
| + | SELECT base_sample.name, | ||
| + | FROM base_sample | ||
| + | LEFT JOIN _be10_al26_quartz ON _be10_al26_quartz.sample_id = base_sample.id | ||
| + | LEFT JOIN _c14_quartz ON _c14_quartz.sample_id = base_sample.id | ||
| + | WHERE (base_sample.lat_DD > 31 AND base_sample.lat_DD < 49) | ||
| + | AND (base_sample.lon_DD > -125 AND base_sample.lon_DD < -104) | ||
| + | |||
| + | </ | ||