Question

Fetching the geometry and attributes from SQL Creator

  • 28 December 2018
  • 2 replies
  • 1 view

Badge

Hi.

I have 2 fetching administrative areas one inside the other. For that, I am having servers to get the data.

When I am running anyone query in SQLCreator, it is working fine separately, but while using union the output is only from the first query. Any comment on this about where am I going wrong.

 

--admin area 0a
(select na.*,aa.geom, aa.name as A09, feat_type, a9_admin_id, a8_admin_id, a7_admin_id,a6_admin_id, a5_admin_id, a4_admin_id, a3_admin_id, a2_admin_id, a1_admin_id from x.mnr_admin_area aajoin x.mnr_admin_area2nameset an on aa.a9_admin_id = an.admin_area_idjoin x.mnr_nameset2name nm on an.nameset_id = nm.nameset_idjoin x.mnr_name na on nm.name_id = na.name_idwhere aa.country='IND' Â and Â na.iso_lang_code='ENG' and aa.feat_type = '112')
union

--admin area 0b
(select na.*,aa.geom, aa.name as A08, feat_type, a9_admin_id, a8_admin_id, a7_admin_id,a6_admin_id, a5_admin_id, a4_admin_id, a3_admin_id, a2_admin_id, a1_admin_id from x.mnr_admin_area aajoin x.mnr_admin_area2nameset an on aa.a8_admin_id = an.admin_area_idjoin x.mnr_nameset2name nm on an.nameset_id = nm.nameset_idjoin x.mnr_name na on nm.name_id = na.name_idwhere aa.country='IND' Â and Â na.iso_lang_code='ENG' and aa.feat_type = '111')

 


2 replies

Userlevel 2
Badge +17

I don't think such a situation could occur.

Just be aware that field names of all resulting records will be equal to ones of the first query in a "union" statement, even if you defined different field names in the second or later queries.

Check again if the number of resulting features from the "union" statement would be equal to the number of features from the first query when executing the queries separately.

Userlevel 2
Badge +16

Another option would be 2 SQLCreator transformers (one for each statement).

Then connect both to the next transformer.

This will be the same as a Union (all).

If you need the distinct Union, use the DuplicateFilter as the next transformer.

Hope this helps.

Reply