Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

select * from table1,table2;

843835Jun 23 2003 — edited Jun 24 2003
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2003
Added on Jun 23 2003
1 comment
2,274 views