SQL query (aliases)

SQL query (aliases)

  

 Hi everyone,


I understood that in SQL query in Outsystems-platform it is impossible to use aliases for tables. Or is there some way?

I tried so:


 SELECT column_name

 FROM table_name as alias_name


 SELECT column_name

 FROM table_name alias_name


 But it doesn't work.


Hi Kate,

This should work:

SELECT column_name
FROM {EntityName} alias_name

Hi Katz,


It is possible.  

Try like this 

SyntaxEditor Code Snippet

SELECT A.[Title],A.[UserLoc_State_Province],B.[Title] from {Location} as A inner join {Location} as B 
 on A.[Title] = b.[Title]

 It works for me

tell us if you have any problems


_Navaneethan

navaneethan m wrote:

Hi Katz,


It is possible.  

Try like this 

SyntaxEditor Code Snippet

SELECT A.[Title],A.[UserLoc_State_Province],B.[Title] from {Location} as A inner join {Location} as B 
 on A.[Title] = b.[Title]

 It works for me

tell us if you have any problems


_Navaneethan

Navaneethan, I used code:


select PeopleName ,( select FruitName + ',' as 'data()' from {Fruit} left join {PeopleFruit} t2 on {Fruit}.[Id]={PeopleFruit}.[FruitId] where t1.Peopleid=t2.Peopleid for xml path('') )
from {People} left join {PeopleFruit} t1 on {People}.[Id]={PeopleFruit}.[PeopleId]
group by PeopleName, Peopleid

But I got an error:


If I remove aliases, the error disappears, but the code does not fulfill the goals I need.

Solution

Hi Kate,


Check the column Names (format) you used, Instead of Peoplename use {Peoplefruit}.[Peoplename].

still you got error, check with your JOIN condition


_Navaneethan

Solution

navaneethan m wrote:

Hi Kate,


Check the column Names (format) you used, Instead of Peoplename use {Peoplefruit}.[Peoplename].

still you got error, check with your JOIN condition


_Navaneethan


Thank you! You have helped me. I added table names and the code earned.