Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » [SOLVED] How to use aliases with SqlExp?
Re: How to use aliases with SqlExp? [message #50328 is a reply to message #50327] Fri, 21 September 2018 11:51 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Patisab wrote on Fri, 21 September 2018 11:08
Good morning Mirek,

When i declare the alias T2 for table T1 as an other ID (with SqlId or with SQLID macro i have compiling errors. This

SqlId T2("T1");
SQL & Select(ID.Of(TABLE),COL1.Of(TABLE),COL2.Of(TABLE),COL1.Of(T2),COL2.Of(T2))
.From(TABLE)
.InnerJoin(TABLE).AsTable(T2).On(ID.Of(T2) == FATHER.Of(TABLE));


results

error: 'class Upp::SqlSet' has no member named 'On'


and that

SqlId T2("T1");
SQL & Select(ID.Of(TABLE),COL1.Of(TABLE),COL2.Of(TABLE),COL1.Of(T2),COL2.Of(T2))
.From(TABLE)
.InnerJoin(T2).On(ID.Of(T2) == FATHER.Of(TABLE));


results

note:   crosses initialization of 'Upp::SqlId T2'


Sorry, i probably not understand your explanations Crying or Very Sad

Best regards.


Ah, sorry I have missed improper use of AsTable. That has a little bit different meaning... (see https://www.ultimatepp.org/src$Sql$SqlExp_en-us.html)

Try this:

SqlId T2("T2");
SQL & Select(ID.Of(TABLE),COL1.Of(TABLE),COL2.Of(TABLE),COL1.Of(T2 ),COL2.Of(T2))
.From(TABLE)
.InnerJoin(TABLE.As(T2)).On(ID.Of(T2) == FATHER.Of(TABLE));

or this:

SqlId T2("T2");
SQL & Select(TABLE(ID ,COL1, COL2), T2(COL1, COL2))
.From(TABLE)
.InnerJoin(TABLE.As(T2).On(ID.Of(T2) == FATHER.Of(TABLE));

BTW, I think you will also need to alias T2.COL1, T2.COL2 to retrieve proper values after fetch...

SqlId T2("T2");
SQL & Select(TABLE(ID ,COL1, COL2), T2(COL1.As("T2_COL1"), COL2.As("T2_COL2")))
.From(TABLE)
.InnerJoin(TABLE.As(T2).On(ID.Of(T2) == FATHER.Of(TABLE));
 
Read Message icon12.gif
Read Message
Read Message
Read Message
Read Message
Previous Topic: Image in QLITE3 database
Next Topic: How to manage the access to a Db on an unstable connection
Goto Forum:
  


Current Time: Tue May 07 08:36:52 CEST 2024

Total time taken to generate the page: 0.02500 seconds