I am trying to execute multiple SQL Queries that SELECT different columns from different tables of the same Database. The results will be pasted to an XML. Is there a way were I can merge the queries and produce a single execute statement?
Below you can find the code I use to execute a single query.
String SQLquery1="SELECT * FROM TABLE1";
String SQLquery2="SELECT P.TITLE, P.LASTNAME, P.FIRSTNAME, P.ADDRESS, PO.POSTCODE, P.SEX FROM TABLE2 P LEFT OUTER JOIN TABLE3 PO ON P.VALUE2= PO.VALUE2";
//Code that exececutes a single query
Statement stmt=null;
Connection db = null;
ResultSet rs=null;
db = DriverManager.getConnection(url);
stmt=db.createStatement();
rs=stmt.executeQuery(SQLquery1);
I was wondering if I can use the executeQuery to execute both of these queries as a single statement or if there is another way to execute them separately. I mean do I have to execute different statements for each query?