Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2004, 01:54 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Comparing certain rows in one table

Sorry, that topic isn't really specific but I'm not exactly sure how to phrase it.

Basically I've been given this rather large database that someone else designed horribly, and I'm looking at one specific table. The two columns in particular I need to look at are called "archive" and "filename".

The archive column consists of either "Printed Copy" or "Electronic Copy". Each filename in this table should have two records associated with it, the "Printed Copy" record and the "Electronic Copy" record.

Is there a way to go through this entire table and basically check to make sure each unqiue filename has both a "Printed Copy" and an "Electronic Copy"... and if they don't output them?

Thanks.

Edit: To get a little more specific:

Filename Archive
-------- -------
aaaa "Printed Copy"
aaaa "Electronic Copy"
bbbb "Electronic Copy"
cccc "Printed Copy"

I would want 'bbbb' and 'cccc' rows to be outputted.
 
Old November 8th, 2004, 02:55 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I think this will do the trick:

SELECT FileName, COUNT(FileName) AS NumRecords
FROM FileNamesTable
GROUP BY FileName
HAVING (COUNT(FileName) = 1)

This ouputs something like this:

FileName NumRecords
BBBB 1
CCC 1

which I think is what you're after.

The SELECT for NumRecords isn't strictly necessary, so you can drop it if you want.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Pretty Tied Up by Guns N' Roses (Track 7 from the album: Use Your Illusion 2) What's This?
 
Old November 8th, 2004, 04:00 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

That works somewhat, but I need to have the archive column in there as well, and if I just add that into the select line, it gives me an error.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing Two values from same table MArgente BOOK: Beginning SQL 3 December 11th, 2009 07:35 AM
comparing rows of two workbooks nasirmunir Excel VBA 2 July 9th, 2008 08:10 PM
comparing rows of two DataGridViews R48 C# 0 November 7th, 2006 04:03 AM
comparing access and Oracle rows pankaj_daga Access 0 August 3rd, 2004 06:29 PM
All rows in a table when in forms nigel_root Access VBA 3 June 2nd, 2004 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.