Skip to main content
Question

sql operation of union

  • January 23, 2020
  • 8 replies
  • 284 views

Forum|alt.badge.img

Hello

How to simply perform a sql operation of union of 2 different database tables ? (not a join)

thanks

8 replies

erik_jan
Contributor
Forum|alt.badge.img+18
  • Contributor
  • January 23, 2020

Hi @jerome,

Two easy ways of doing so in FME:

1) Use the SQLCreator transformer to do the Union using SQL in the database

2) Read both tables and lead the output to the first transformer or writer. If you need a UNION and not UNION ALL, you will need to filter out the duplicates by using the DuplicateFilter transformer.

Hope this helps.


Forum|alt.badge.img
  • Author
  • January 23, 2020

Thanks... I tried the first solution but it failed because I could not write the correct table 's name from different database. And for the second one I obtain too much different column attribut...

I try again


robotix
Contributor
Forum|alt.badge.img+10
  • Contributor
  • January 23, 2020

InlineQuerier: works for me. Union Statement.

I've found that dropping schema prefixes sometimes helps with naming-if possible. So for instance dbo.tableX may not work in some transformers but if you change it at the reader level to come in as tableX it works fine.


Forum|alt.badge.img
  • Author
  • January 27, 2020
robotix wrote:

InlineQuerier: works for me. Union Statement.

I've found that dropping schema prefixes sometimes helps with naming-if possible. So for instance dbo.tableX may not work in some transformers but if you change it at the reader level to come in as tableX it works fine.

this transformer seems to be dedicated to SQLite database tables.

 

 


Forum|alt.badge.img
  • Author
  • January 27, 2020

Do you know a documentation dedicated to multi database access ?


robotix
Contributor
Forum|alt.badge.img+10
  • Contributor
  • January 27, 2020
robotix wrote:

InlineQuerier: works for me. Union Statement.

I've found that dropping schema prefixes sometimes helps with naming-if possible. So for instance dbo.tableX may not work in some transformers but if you change it at the reader level to come in as tableX it works fine.

It may use SQLite syntax but you can use it with a variety of result sets. I have used it with Oracle, MSSQL, CSV and Excel result sets. Feed your results into the InlineQuerier the create the statement.

In the eaxmple below I use a MSSQL DB and join a spreadsheet with 'union all':

 


Forum|alt.badge.img
  • Author
  • January 28, 2020
robotix wrote:

It may use SQLite syntax but you can use it with a variety of result sets. I have used it with Oracle, MSSQL, CSV and Excel result sets. Feed your results into the InlineQuerier the create the statement.

In the eaxmple below I use a MSSQL DB and join a spreadsheet with 'union all':

 

Thanks it's just what I want ... but I'm surprised there is no native way to do the sql union operation


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • January 29, 2020

@jerome

  1. UNION or UNION ALL is the "native" way to append SELECT statement results together within SQL syntax
  2. In FME, that same can also be achieved with Features by connecting them to a common Transformer, such as a Junction, AttributeManager etc. like so. In the example below, if there are 200 Features coming in from "HeadMeters" and 100 Features coming in from "Properties, then 300 Features will enter and exit the AttributeManager


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings