26 lines
975 B
SQL
26 lines
975 B
SQL
with selection as (
|
|
select op.id, product_name, brands, "energy-kcal_100g", fat_100g, "saturated-fat_100g",
|
|
"carbohydrates_100g", "sugars_100g", "proteins_100g", "salt_100g", "fiber_100g",
|
|
"nutriscore_score", "additives_n", string_to_array(additives_en, ','),
|
|
"potassium_100g", "calcium_100g", "vitamin-a_100g", "vitamin-c_100g",
|
|
main_category_en
|
|
from openfoodfacts_cleaned op
|
|
left join produit p on p.id = op.id
|
|
where brands like 'Nestlé%'
|
|
and p.id is null
|
|
and "energy-kcal_100g" is not null
|
|
and proteins_100g is not null
|
|
and fat_100g is not null
|
|
and "saturated-fat_100g" is not null
|
|
and carbohydrates_100g is not null
|
|
and sugars_100g is not null
|
|
and salt_100g is not null
|
|
and nutriscore_score is not null
|
|
)
|
|
insert into produit (id, nom, marque,
|
|
energie, graisse, graisse_saturee,
|
|
glucide, sucre, proteines, sel,
|
|
fibres, nutriscore, additifs, additifs_list,
|
|
potassium, calcium, vitamin_a, vitamin_c, categorie)
|
|
select * from selection;
|