Skip to main content
5-Regular Member
November 17, 2016
Question

How to get output of a sql query which has multiple fields with same name?

  • November 17, 2016
  • 3 replies
  • 1873 views

Hello,

I want to create a ThingWorx service with sql query. The sql query contains joins and it outputs data in the following fields:

     username | action | eventdate | action | eventdate

As you see, the output has fields with same name. Hence, when I run this service, it shows only 3 unique columns i.e. username, action and eventdate.

I need to see all fields in my output. As the datashape accepts only unique field names, how can get output of this service with all columns?

Thanks,

Shravan

3 replies

5-Regular Member
November 17, 2016

Sorry, I am a bit confused. Why is your SQL query returning two fields with the same name? I believe it is not good design to have two tables with similarly named columns if you intend to join them at some point. Won't SQL have issues querying the joined table as well? Perhaps you could return these tables separately and manually combine them within a service in ThingWorx.

1-Visitor
November 17, 2016

Rename the fields before doing the join with RenameField snippet.

sgaggad5-Regular MemberAuthor
5-Regular Member
November 18, 2016

Thanks for your inputs. I could resolve the issue by modifying the sql query and using alias for the duplicate fields.