Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Need a SQL Query (URGENT)

Author  Topic 

grajesh_955
Starting Member

5 Posts

Posted - 2008-05-16 : 05:12:10
Hi Folks,

I have 2 tables, in which the 1st one has 200 columns and 2 table had 2 columns.. There is one common column for both the tables, but there is little change in schema of the tables...The common col in 2nd table is a primary key but the same column in the 1st table is a ordinary one..

Now i need to write a query to select 199columns(except the common column)from the 1st table and the other column(2nd col)other than the common column frm the 2nd table for "table1.commoncolumn=table2.commoncolumn"......

I had tried the natural join but its nt working in my informix sql database....I also tried by explicitly mentioning column names like "select column1,column2....column199,table2.column2 from table1,table2 where table1.commoncolumn=table2.commoncolumn", but its having a severe performance impact.......

Can some please suggest a query for this?? Thankx in advance..

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-16 : 05:16:03
hi

is ur common column's datatype are same in both tables

ok
Go to Top of Page

grajesh_955
Starting Member

5 Posts

Posted - 2008-05-16 : 05:18:29
Yah dude......
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-16 : 05:38:41
ok
then whats ur actual problem?
is it an error then pls post ur query..

ok
Go to Top of Page

grajesh_955
Starting Member

5 Posts

Posted - 2008-05-16 : 05:40:14
I need query to select those columns based on the above criteria!!!
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-16 : 06:03:52
then try this

select a.column2,a.column3....a.column200,b.column2
from
table1 a
inner join
table2 b
where a.column1=b.column1

ok tanx..
Go to Top of Page

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2008-05-16 : 16:06:14
quote:

I had tried the natural join but its nt working in my informix sql database



This is not an informix forum. This is for MS SQL Server 2000

Natural joins aren't supported in SQL server anyway.



An infinite universe is the ultimate cartesian product.
Go to Top of Page

ssunny
Posting Yak Master

133 Posts

Posted - 2008-05-19 : 13:23:33
quote:
Originally posted by grajesh_955

Hi Folks,

I have 2 tables, in which the 1st one has 200 columns and 2 table had 2 columns.. There is one common column for both the tables, but there is little change in schema of the tables...The common col in 2nd table is a primary key but the same column in the 1st table is a ordinary one..

Now i need to write a query to select 199columns(except the common column)from the 1st table and the other column(2nd col)other than the common column frm the 2nd table for "table1.commoncolumn=table2.commoncolumn"......

I had tried the natural join but its nt working in my informix sql database....I also tried by explicitly mentioning column names like "select column1,column2....column199,table2.column2 from table1,table2 where table1.commoncolumn=table2.commoncolumn", but its having a severe performance impact.......

Can some please suggest a query for this?? Thankx in advance..

Go to Top of Page

ssunny
Posting Yak Master

133 Posts

Posted - 2008-05-19 : 13:36:43
Try this:

select a.2,a.3,a.4.... a.199,b.2
from table a,table b
where a.1 = b.1
Go to Top of Page
   

- Advertisement -