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
 Need Help

Author  Topic 

NamrataC
Starting Member

5 Posts

Posted - 2009-09-09 : 02:41:42
Hi,
I'm a novice to the query world.
I'm trying to make a select query where I have to select 'rate' from table 'A' if the rate has not been changed in table 'B'. The table 'B' has code of table 'A' as foreign key.
Someone please help me to make this query.

Hoping for quick response. Thanking you in anticipation.

ra.shinde
Posting Yak Master

103 Posts

Posted - 2009-09-09 : 02:47:48
can you post table structure?

Rahul Shinde
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-09-09 : 05:00:08
[code]
select a.rate
from tableA a
where exists
(
select *
from tableB b
where b.code = a.code
and b.rate = a.rate
)

OR

select a.code, a.rate
from tableA a
inner join tableB b on a.code = b.code
where a.rate = b.rate
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -