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
 Joins

Author  Topic 

vallamreddy123
Starting Member

3 Posts

Posted - 2008-02-27 : 01:31:10
Hi

I just want to compare two columns of two tables in a single query.

Actually i am new for sql server. can anybody help me in this issue.

Thanks N Regards,
Vallamreddy VenuGopal

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-02-27 : 01:36:35
What sort of comparison do you want to make - for example , if they values are the same ?


Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-27 : 01:38:40
Please post your table structures with some sample data & expected o/p
Go to Top of Page

vallamreddy123
Starting Member

3 Posts

Posted - 2008-02-27 : 01:49:09
Thank u Jack for ur reply.

Yes the values are same. Both fileds are having same constraints.



quote:
Originally posted by jackv

What sort of comparison do you want to make - for example , if they values are the same ?


Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com


Go to Top of Page

vallamreddy123
Starting Member

3 Posts

Posted - 2008-02-27 : 01:54:19
Hi,

The table structure is like as below.

First Table:

AMName AMCOde
-------------
venu 1233
gopal 4563
sunil 7895
second table:

AMName isactive
------------------------
venu 1
gopal 0
ramesh 1

Now i want to comapre these two tables and i want to retreive only the AMNames whose active status is one from the first table

quote:
Originally posted by visakh16

Please post your table structures with some sample data & expected o/p

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-27 : 02:06:11
SELECT t1.*
FROM FirstTable t1
INNER JOIN SecondTable t2
ON t2.AMName=t1.AMName
AND t2.isactive=1
Go to Top of Page
   

- Advertisement -