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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

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

sgaggad
5-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
ttielebein
12-Amethyst
(To:sgaggad)

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.

Rename the fields before doing the join with RenameField snippet.

sgaggad
5-Regular Member
(To:sgaggad)

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

Top Tags