473,549 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql comparison and flag

I need to compare two tables and print the differences(vbs cript). Is
there a quick sql way to do this. Otherwise I have a O(n^2) problem.

What I am doing now is getting the data from the 2nd table first and
then printing the 1st table and checking if the value matches the 2nd
table. O(n^2)

lets say I have ids

Get Table 2 data

3 4 5

Print Table 1 and Flag:

1 - no O(n)
2 - no O(n)
3 - yes O(n)
4 - yes O(n)
5 - yes O(n)
6 - no O(n)

Is there a better way?
Jul 19 '05 #1
3 5173
bigbinc wrote:
I need to compare two tables and print the differences(vbs cript). Is
there a quick sql way to do this. Otherwise I have a O(n^2) problem.

What I am doing now is getting the data from the 2nd table first and
then printing the 1st table and checking if the value matches the 2nd
table. O(n^2)

lets say I have ids

Get Table 2 data

3 4 5

Print Table 1 and Flag:

1 - no O(n)
2 - no O(n)
3 - yes O(n)
4 - yes O(n)
5 - yes O(n)
6 - no O(n)

Is there a better way?


Define better.

(SELECT * FROM TABLE1
MINUS
SELECT * FROM TABLE2)
UNION
(SELECT * FROM TABLE2
MINUS
SELECT * FROM TABLE1)

Jul 19 '05 #2
"Anna C. Dent" <an******@hotma il.com> wrote in message news:<BlCmb.848 86$Ms2.45276@fe d1read03>...
bigbinc wrote:
I need to compare two tables and print the differences(vbs cript). Is
there a quick sql way to do this. Otherwise I have a O(n^2) problem.

What I am doing now is getting the data from the 2nd table first and
then printing the 1st table and checking if the value matches the 2nd
table. O(n^2)

lets say I have ids

Get Table 2 data

3 4 5

Print Table 1 and Flag:

1 - no O(n)
2 - no O(n)
3 - yes O(n)
4 - yes O(n)
5 - yes O(n)
6 - no O(n)

Is there a better way?


Define better.

(SELECT * FROM TABLE1
MINUS
SELECT * FROM TABLE2)
UNION
(SELECT * FROM TABLE2
MINUS
SELECT * FROM TABLE1)


Well, lets just say I have 200 records in one table and 200 records in
another table, that is 200 * 200 calculations. Between
vbscript,oracle , my-brain, and somebody else's brain, there is
probably a better way.
Jul 19 '05 #3


bigbinc wrote:
"Anna C. Dent" <an******@hotma il.com> wrote in message news:<BlCmb.848 86$Ms2.45276@fe d1read03>...
bigbinc wrote:
I need to compare two tables and print the differences(vbs cript). Is
there a quick sql way to do this. Otherwise I have a O(n^2) problem.

What I am doing now is getting the data from the 2nd table first and
then printing the 1st table and checking if the value matches the 2nd
table. O(n^2)

lets say I have ids

Get Table 2 data

3 4 5

Print Table 1 and Flag:

1 - no O(n)
2 - no O(n)
3 - yes O(n)
4 - yes O(n)
5 - yes O(n)
6 - no O(n)

Is there a better way?


Define better.

(SELECT * FROM TABLE1
MINUS
SELECT * FROM TABLE2)
UNION
(SELECT * FROM TABLE2
MINUS
SELECT * FROM TABLE1)

Well, lets just say I have 200 records in one table and 200 records in
another table, that is 200 * 200 calculations. Between
vbscript,oracle , my-brain, and somebody else's brain, there is
probably a better way.


There is a better way,
but you have to think smarter rather than a brute force.

If you can read from table1 & table2 in the same order,
then only 1 full table scan of each table is required.

Jul 19 '05 #4

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

Similar topics

17
2028
by: Andreas Koch | last post by:
Hi all, i started a little "practical language comparison" - practical in the sense that i compare how actual distributions and versions and their libraries (not abstract language specifications) solve small test cases like the 8 queens problem. Currently there are contributions for 17 different languages, and none for Phyton (and Lisp....
3
4545
by: Jim Archer | last post by:
Hi All... I'm been fighting this problem for a few days now, and it seems like it should be simple. But the solution has eluded me so far... I need to flag a record when it is updated or when it is a new insert. Then I SELECT for the changed records and do something not related to Postgres. Easy enough, I created a trigger procedure and...
1
1992
by: starffly | last post by:
In my program, the calculated value is supposed to be no more than the constants named MAXINT,otherwise, the overflow error will be reported, however, I cannot test if the value exceeds MAXINT within the integer scope smaller than MAXINT, so I want to seek a solution to test the excess without comparing the value with MAXINT. Please let me...
4
2710
by: Bucco | last post by:
I am trying to compare a list of items to the list of files generated by os.listdir. I am having trouble getting this to work and think I may be going down the wrong path. Please let me know if hter is a better way to do this. THis is what I have for my class so far: import os, sys class MatchList: def __init__(self, dir, file):...
7
1798
by: matt | last post by:
hello, i have been given a challenging project at my org. i work on an inventory management web application -- keeping tracking of parts assigned to projects. in the past, i built an in-house ASP.NET reporting system. just your standard stuff -- user clicks on a report, the page executes a pre-defined SQL query, a dataset is formed and...
9
1188
by: atbusbook | last post by:
I'm doing a report on the speed of develipment and executionin varius programing langiuiges. write code for all these tasks in the languige of your choise if intrestied send code to atbusbook@aol.com. Task 1: write a program that prints how many times you repeat all words in a file passed as a comand line paramiter and from STDIN. with the...
3
1246
by: Russ | last post by:
I posted a message on this several days ago, but it apparently got lost in googlespace, so I'll try it again. I recently discovered a bug in my code that apparently resulted from the automatic conversion of a function pointer to an integer. Say you have a class member function called getCount(), which returns an integer. Now suppose you...
12
4471
by: Daniel Earwicker | last post by:
I wrote two trivial test programs that do a billion iterations of a virtual method call, first in C# (Visual Studio 2005): Thing t = new DerivedThing(); for (System.Int64 n = 0; n < 10000000000; n++) t.method(); Then in C++ (using Visual C++ 2005): Thing *t = new DerivedThing();
2
198
by: bigbinc | last post by:
I need to compare two tables and print the differences(vbscript). Is there a quick sql way to do this. Otherwise I have a O(n^2) problem. What I am doing now is getting the data from the 2nd table first and then printing the 1st table and checking if the value matches the 2nd table. O(n^2) lets say I have ids Get Table 2 data
0
7986
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7504
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6074
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5391
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3518
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3499
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1083
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.