query sync ads impressn

mail@pastecode.io avatar
unknown
pgsql
16 days ago
2.0 kB
5
Indexable
Never
update ads_impressions
set logs = (select name from advertises where advertises.id = ads_impressions.advertise_id) || ' ' ||
           (select ads_id from advertises where advertises.id = ads_impressions.advertise_id) || ' ' ||
           (select lokasi_nama
            from master_propinsis
            where master_propinsis.lokasi_propinsi = ads_impressions.province_id) || ' ' ||
           (select lokasi_nama
            from master_kabkos
            where master_kabkos.lokasi_propinsi = ads_impressions.province_id and master_kabkos.lokasi_kabupatenkota = ads_impressions.city_id) || ' ' ||
           (select lokasi_nama
            from master_kecamatans
            where master_kecamatans.lokasi_propinsi = ads_impressions.province_id and master_kecamatans.lokasi_kabupatenkota = ads_impressions.city_id and master_kecamatans.lokasi_kecamatan = ads_impressions.subdistrict_id)
where ads_impressions.logs is null
  and advertise_id != 0
  and advertise_id is not null;

update ads_impressions
set logs = (select name from projects where projects.id = ads_impressions.project_id) || ' ' ||
           (select id_listing from projects where projects.id = ads_impressions.project_id) || ' ' ||
           (select lokasi_nama
            from master_propinsis
            where master_propinsis.lokasi_propinsi = ads_impressions.province_id) || ' ' ||
           (select lokasi_nama
            from master_kabkos
            where master_kabkos.lokasi_propinsi = ads_impressions.province_id and master_kabkos.lokasi_kabupatenkota = ads_impressions.city_id) || ' ' ||
           (select lokasi_nama
            from master_kecamatans
            where master_kecamatans.lokasi_propinsi = ads_impressions.province_id and master_kecamatans.lokasi_kabupatenkota = ads_impressions.city_id and master_kecamatans.lokasi_kecamatan = ads_impressions.subdistrict_id)
where ads_impressions.logs is null
  and ads_impressions.project_id != 0
  and ads_impressions.project_id is not null;
Leave a Comment