comparing 2 tables columns if they match or not

  • check if any records match

    if match ---rec match/not match

    when used full outer join both tables

    no name ph

    1 X 0

    2 Y 1

    3 Z 2

    4 A 3

    no name ph

    1 X 0

    2 c 6

    3 m 9

    4 A 5

    no name ph result

    1 X 0 null--------------------------why im getting nul when there are records?

    2 c 6 rec found

    3 m 9 rec found

    4 A 5 null------------------------why im getting nul when there are records?

    5 Y 1 rec found

  • Please post your exact query, and the actual data you are running.

    (1) We need to know what columns you are joining ON. Row 1 in both tables is identical. There is no join on any combination of those columns that will produce the result you say you are getting.

    (2) Where is No 5 coming from in your result? It doesn't exist in the sample data you just posted. Together with the impossible non-match for the first row, this leads me to believe you may not be actually joining the tables you think you are joining. Double check that first thing.

    (3) Are you actually evaluating something to produce the string in your result column? If so, there may be something about that test which is in error. But until you show us your code we can't very well help you find the error.

    If you want help, you should take the time to post your data, your code, and your results, or error, or desired results EXACTLY. If we can recreate your problem, we can resolve it. Being vague works against you getting a quick and correct answer. Go back over and do it again right, and someone will be able to assist you.

    When you have time, read this article. [/url] Submitting your questions in this fashion will get you tested answers quicker and win you friends among the volunteers who take the time to help you out.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Sadly - as Bob stated - it's a bit difficult to help that way.

    However, please try using CHECKSUM(*) or BINARY_CHECKSUM(*) to allow for single key comparison.

    Note that there's a slight chance you'll be missing something, but it's a good function to start with

  • CHECKSUM(*) is a neat method to identify different records... thanks for the memory refresh 🙂

  • Also you can use INTERSECT and EXCEPT to find row matches

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply