Home » U++ Library support » U++ SQL » [SOLVED] How to join two tables from two schemas with SqlExp
Re: How to join two tables from two schemas with SqlExp [message #50849 is a reply to message #50841] |
Wed, 09 January 2019 09:22   |
 |
mirek
Messages: 14267 Registered: November 2005
|
Ultimate Member |
|
|
Patisab wrote on Tue, 08 January 2019 15:06So is it possible? If it is, how?
#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
Sqlite3Session sqlite3;
sqlite3.SetTrace();
SQL = sqlite3;
SqlId T1("T1"), Col1("Col1"), Col2("Col2");
SQLID(T2); SQLID(S2);
SQL * Select(T1(Col1), T1(Col2), T2(Col2), T2(Col2))
.From(T1)
.InnerJoin(S2(T1).As(T2))
.On(T2(Col1) == T1(Col2));
}
produces
select T1.Col1, T1.Col2, T2.Col2, T2.Col2 from T1 inner join S2.T1 T2 on T2.Col1 = T1.Col2
SQLID(T1) and SqlId T1("T1") are equivalent. Also, if you are using .sch files, you can do the same thing by adding '_' to type (like INT_ (Col1) or TABLE_(T1)).
Col1.Of(T1) and T1(Col1) are equivalent (parenthesis form is 'more modern').
You cannot write "S2.T1" - we cannot support that, as C++ does not have "operator." overloading 
Mirek
[Updated on: Wed, 09 January 2019 09:23] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Aug 28 01:13:53 CEST 2025
Total time taken to generate the page: 0.00286 seconds
|