SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Comparing one field that is in two tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 03/05/2007 :  10:45:46  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Ann writes "Ok, I wanted to test my SELECT stmt in SQL Query Analyzer before I put it in prodcution. I place a select stmt to compare the acctnum in one table with the acctnum in another table, but not all of the records come up. I did check the ones that didnt come up from the first file and they were in the second file but it didn't show up.

Is there something I am missing. Here is the code I am using:

select dbo.scrub_return.acctnum, dbo.scrub_return.found,
dbo.bi_prescrub.acctnum
from dbo.scrub_return, dbo.bi_prescrub
where dbo.scrub_return.acctnum =
dbo.bi_prescrub.acctnum and found=' '"

spirit1
Cybernetic Yak Master

Slovenia
11750 Posts

Posted - 03/05/2007 :  11:38:36  Show Profile  Visit spirit1's Homepage  Reply with Quote
you want to test it only in QA? That'll be stable

use join syntx.

well the way you have it written the returned records will be those that have the same
acctnum and dbo.scrub_return.found = ' '

is that what you want??

Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

aboltz
Starting Member

1 Posts

Posted - 03/05/2007 :  15:04:03  Show Profile  Send aboltz a Yahoo! Message  Reply with Quote
spirit 1: Yes, that is what I want. Whatever the acctnum is in scrub_return to find it in the bi_prescrub table. I have tried the join syntx but received the same number of acctnums returned.

Is there a way to put after dbo.scrub_return.acctnum or dbo.bi_prescrub, which would mean to get everything after in the acctnum field to make sure there is no ambigious characters or such.
Go to Top of Page

JohnH
Starting Member

13 Posts

Posted - 03/06/2007 :  15:56:51  Show Profile  Reply with Quote
I'm having a hard time understanding what you want to accomplish. Can you try asking the question another way?

John Hopkins
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17584 Posts

Posted - 03/06/2007 :  16:52:39  Show Profile  Reply with Quote
try removing the found = '' clause ?

select dbo.scrub_return.acctnum, dbo.scrub_return.found,
       dbo.bi_prescrub.acctnum
from   dbo.scrub_return inner join dbo.bi_prescrub
on     dbo.scrub_return.acctnum = dbo.bi_prescrub.acctnum 
where  found =' '



KH

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000