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 » Select from two temporary tables
Select from two temporary tables [message #38027] Wed, 28 November 2012 19:47 Go to previous message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi,

I need to select columns from two temporary tables, but there is no version of From that takes two SqlSets.

Can you Mirek add this to Sqlexp.h and SqlStatement.cpp:

SqlSelect& From(const SqlSet& set1, const SqlSet& set2);

SqlSelect& SqlSelect::From(const SqlSet& table1, const SqlSet& table2) {
	String ts1 = table1(SqlSet::SETOP + 1);
	String ts2 = table2(SqlSet::SETOP + 1);
	text = "select " + text + " from " + ts1 + ", " + ts2;
	tables << ',' << Filter(ts1, CharFilterNotWhitespace);
	tables << ',' << Filter(ts2, CharFilterNotWhitespace);
	on = false;
	return *this;
}


BTW. Postgres doesn't like parentheses around embeded select, so
AsTable should look like this:

SqlSet SqlSelect::AsTable(const SqlId& tab) const
{
	StringBuffer t;
	t << SqlCase(MSSQL|PGSQL, "")("(") //<---PGSQL added
	<< "(" << text << ") as \t" << tab.ToString() << '\t'
	<< SqlCase(MSSQL|PGSQL, "")(")");  //<---PGSQL added
	return SqlSet(String(t), SqlSet::HIGH);
}

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Sqlite DB readonly
Next Topic: Some unexpected differences between Sqlite3 and MySql in Upp
Goto Forum:
  


Current Time: Sun Apr 28 14:31:28 CEST 2024

Total time taken to generate the page: 0.02548 seconds