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
 General SQL Server Forums
 New to SQL Server Programming
 having trouble selecting from 2 tables. Simple sim

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2013-09-13 : 13:12:12
SELECT IDDOCD,IDCOM#, IDPRT#, IDGRC#,
IDENT#,IDSFX#,IDPRLC, IDNTU$, IDSHP#, IDINV# from astdta.oeind94,
SELECT IARCC9 from astdta.icprt1

each select alone is ok. how do you combine these?

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-13 : 13:19:51
Something like this perhaps? You have to find some relationship between the two tables i.e., some column or columns on which to JOIN them
SELECT 
IDDOCD,IDCOM#, IDPRT#, IDGRC#,
IDENT#,IDSFX#,IDPRLC, IDNTU$, IDSHP#, IDINV# , IARCC9
from astdta.oeind94 o
INNER JOIN astdta.icprt1 i ON i.SomeColumnIn_oeind94 = o.SomeColumnIn_oeind94
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2013-09-13 : 13:22:04
I see. OK because I am taking something that the crystal reports makes and trying to apply it on the server. Thanks for the help, James.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-09-15 : 04:09:02
unless you specify a relation what you would end up would be a cartesian product.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -