473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Unusual Query

SQL Server 2000

I need to compare 2 tables as follows:

Table 1 - Accounts
Acct#, Account Name

Table 2 - Ledger
(Among Others)
Acct#,AccountName

I would like to create a view where the account number matches in both tables but the account name does not.

I.e.

Table 1:
5000 Maintenance

Table 2:
5000 Maintenance
5000 Maintenance
5000 Building Maintenance

my query view would display:
5000 Building Maintenance

indicating there is a "Bad Record" and I would do some processing from there.

FYI - I know I could prevent this easily, but I am actually comparing several databases with Table 2 data with a central Table 1 database.

TIA

--
Tim Morrison

--------------------------------------------------------------------------------

Vehicle Web Studio - The easiest way to create and maintain your vehicle related website.
http://www.vehiclewebstudio.com
Jul 20 '05 #1
2 1241
You can do a simple EXISTS check like:

SELECT *
FROM tbl2
WHERE NOT EXISTS ( SELECT *
FROM tbl1
WHERE tbl1.Acct# = tbl2.Acct#
AND tbl1.acc_name = tbl2.acc_name );

--
- Anith
( Please reply to newsgroups only )
Jul 20 '05 #2
This should do the trick:

SELECT
table1.acct,
Table2.name

FROM
table1,
table2

where
table1.acct = Table2.acct
AND table1.name <> Table2.name
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Powell | last post by:
Here is the scope of what I need to do; want: enrollment_year allowed (even if null) all of ica criteria:
4
by: Larry R Harrison Jr | last post by:
I have an Access 2000/XP with an unusual autonumber scheme; I can't figure out how it generates its very unique value. I have the database temporarily located at this website: ...
3
by: Farooq Khan | last post by:
why does Response.Write in a method of code-beind class when called from inpage code (i.e in <%---%>), after creating object of that class, fails when called while it works perfectly ok while...
15
by: John Howie | last post by:
I've found very unusual behavious when using sessions on two different servers. I'm using sessions to handle simple log in. When the form submits the values are checked against a MySQL table. If...
1
by: Dunc | last post by:
I have a site with a number of pages that make use of an ID and an anchor in the querystring (e.g. www.mysite.com/news.aspx?NewsTypeID=7#NewsID_49). For some reason, when it's visited by a...
4
by: coolhand729 | last post by:
Okay, this is not your normal two table query (at least it doesn't seem that way to me). I'm using Access 2000 on Windows XP. I have two tables in access. One is a table with addresses of club...
18
by: cov | last post by:
I have a query where I'm attempting to pull data from 3 different tables using php and mysql. I had hoped to have a unique identifier to help ensure referential integrity but it appears that...
7
by: cov | last post by:
I have a php query where I'm attempting to pull data from 3 different tables between a php form and mysql db. I had hoped early on to use a unique identifier to help ensure referential integrity...
10
by: sheldonlg | last post by:
I got an unusual request. One customer wants a password/access made available to a user that is valid for only, say, ten minutes. I know that I can enforce this by having a revalidation of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.