Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using sql queries as a string in JAVA

Status
Not open for further replies.

memphisTNdev22

Programmer
Jan 3, 2006
7
US
I am trying to union three queries as a string and my last select statement is attaching to the union..
For example.

String s1 ="select * from table"
String s2 = "select * from table"
String s3 = "select * from table"

String s4 = " s1 + " UNION " + s2 + "UNION" +s3 ;"

The output looks like

select * from table union select * from table unionselect *from table.
 
You don't actually say what you want your output tp be like, but I'm guessing it is :

String s4 = " s1 + " UNION " + s2 + " UNION " +s3 ;"

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
yes, i need the final query to say..

select * from table union select * from table union select * from table

Currently it is attaching as

select * from table union select * from table unionselect * from table

The union is attaching to the select statement


 
Well use the code I posted above then (you are missing two spaces) ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top