Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 June 4th, 2004, 11:00 AM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Seb_soum
Default Compare 2 tables....

I have 2 tables. tblJobs and tblquotes. I need an ASP page to compare 4 fields in each, if it meets the criteria, then write to HTMl.
the fields in both are:
surname, forname, dest_code. These have to match exactly, but then the 4th field "who_create" has to be different....so any help would be appreciated......thanks guys
 
Old June 4th, 2004, 11:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Just open two recordsets, one for each table, and compare the fields by

if ( objRS("surname") = objRS2("surname") ) then
... etc ...

Is this even close to what you are looking for? Are we talking one record or more than one? In addition, what database are you using?

Thanks,

Brian
 
Old June 4th, 2004, 05:47 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think this syntax is correct for an ASP union query and it might work. I'm just not sure if it grabs distinct out of each table or both without trying it out first. Either way it is pretty close to what you need without having to compare things with your code.

sql = "select distinct tblJobs.SurName AS SurName, tblJobs.ForName AS ForName,"
sql = sql & " tblJobs.Dest_Code AS DestCode tblJobs.Who_Create AS WhoCreate"
sql = sql & " from tblJobs"

sql = sql & " unionall"

sql = sql & "select distinct tblQuotes.SurName AS SurName, tblQuotes.ForName AS ForName,"
sql = sql & " tblQuotes.Dest_Code AS DestCode tblQuotes.Who_Create AS WhoCreate"
sql = sql & " from tblQuotes"

sql = sql & " order by whatever...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare 2 tables in 2 different DBs Feodorov SQL Server 2005 4 March 7th, 2008 08:08 AM
Compare two fields from different tables pallone SQL Server 2000 10 March 23rd, 2007 05:14 PM
Compare records between two tables jaaboston Access VBA 1 December 21st, 2006 05:35 AM
compare these date fields and compare and get the susanring Oracle 1 July 24th, 2006 04:58 PM
how to compare tables data ramanadyv SQL Language 0 April 10th, 2006 04:38 AM





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