What is wrong with the following command string? 1 command = "select field1, field2 from table1 " + 2 "select fld1, fld2 from table2"; 3 4 rs.executeQuery(command); 5 6 field1 = rs.getString(field1); 7 field2 = rs.getString(field2); 8 fld1 = rs.getString(fld1); 9 fld2 = rs.getString(fld2); I get an error on line 8 saying that fld1 is an invalid column name. What is the fix to it? TIA jacq carballo
There's two basic problems with your code, I think. One is that it's very dodgy to just string two select statements together like that. There's no guarantee what the database will do with it. I'd suggest doing each of the two selects as a separate query with a separate resultset. The second problem is that you need to quote the names in your call to getString. The argument to getString is the name of the column, not a variable.