Hello,
I am trying to make a query like this
rs = st.executeQuery("select * from table1,table2)
while(rs.next())
{
int i = rs.getInt(1);
String s1 = rs.getString(2);
String s2 = rs.getString(3);
System.out.println(i);
System.out.println(s1);
System.out.println(s2);
}
I need to get all of the records present in both the tables. My table structure is
create table1(slno int,fname varchar(20),descr text);
create table2(slno int,fname varchar(20),descr text);
I am using SQL Server. The problem is I get table1 * table2 records (i.e if table1 has
5 records and table2 has 3 records, I get 5 * 3 = 15 records). I tried changing the query
as
select slno,fname,descr from table1 union select slno,fname,descr from table2)
This query gives an error distinct is not allowed for text,ntext or image datatype.
Can any one help me with this problem?
Thanks