|
|
Question : return multiple resultsets with TsqlQuery
|
|
|
|
in Delphi 2010 Is there a way to return (and parse) multiple resultsets from SQL using TSQLQuery? if not - is there anything else that can be used?
PLEASE DO NOT SUGGEST USING VIEWS the tables have NOTHING in coomon or any possible jjoined data structures
For example - all 3 queries.. 1: select id,fiield1, field2 from table1 nolock where status>0 2: select id,fiield1, field2 from table2 nolock where status>0 3: select id,fiield1, field2 from table3 nolock where status>0
tia
SAMPLE CODE is ALWAYS prefered ;)
|
|
|
|
Answer : return multiple resultsets with TsqlQuery
|
|
if the queries have no resemblence to one another, you can still combine them providing they don't have too much columns using union
select 'table1' table_column, a column1, b column2, c column3, d column4, e column5, f column6, null column7, null column8 from table1 union select 'table2' table_column, d column1, e column2, f column3, a column4, c column5, null column6, null column7, b column8 from table2 union select 'table3' table_column, b column1, c column2, d column3, e column4, f column5, null column6, a column7, null column8 from table3 union select 'table4' table_column, f column1, a column2, null column3, e column4, b column5, null column6, c column7, d column8 from table4
this is how you can read from multiple tables with 1 query and have 1 result
|
|
|
|