sql comparison and flag

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bigbinc

    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?
  • Anna C. Dent

    #2
    Re: sql comparison and flag

    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)

    Comment

    • bigbinc

      #3
      Re: sql comparison and flag

      "Anna C. Dent" <anacdent@hotma il.comwrote 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.

      Comment

      Working...