Skip to content

Instantly share code, notes, and snippets.

@dlcoffee
Last active February 28, 2019 22:23
Show Gist options
  • Save dlcoffee/e17fca23de26f5e516e346bbdeccd7a9 to your computer and use it in GitHub Desktop.
Save dlcoffee/e17fca23de26f5e516e346bbdeccd7a9 to your computer and use it in GitHub Desktop.
toan help
// titles
id | title_type | parent_title_id
1 | series |
2 | feature |
3 | season | (1)
// external_titles
id | title_id | system_name | system_id | data
1 | 1 | 'radar' | 111 | { radar_product_profile: { product_id: 111, product_num: 123 } }
2 | 3 | 'radar' | 222 | { radar_product_profile: { product_id: 222, product_num: 456 } }
3 | 2 | 'radar' | 333 | { radar_product_profile: { product_id: 333, product_num: 123 } }
UPDATE
titles t
SET
parent_title_id = series_titles.id
FROM
titles series_titles
JOIN external_titles et_series ON et_series.title_id = series_titles.id
JOIN titles season_titles ON season_titles.title_type = 'season'
JOIN external_titles et_seasons ON et_seasons.title_id = season_titles.id
WHERE
t.title_type = 'season'
AND series_titles.title_type = 'series'
AND et_seasons.system_name = 'radar'
AND et_series.system_name = 'radar'
AND et_seasons.data -> 'radar_product_profile' ->> 'product_num' = et_series.data -> 'radar_product_profile' ->> 'product_num';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment