cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
Regular Member

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

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 3
Highlighted

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

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.

Highlighted

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

Rename the fields before doing the join with RenameField snippet.

Highlighted

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

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

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!