Comparing two fields in a table

  • Hi,

    i have a table with few fields, and all i want is compare two fields with in the table, so that where the two fields not matching return those rows, as both fields need to have same data.

    Can some one guide me how do i query with in the same table, or any other way.

    Many Thanks

    Nomi

  • Whats the problem in using the two columns in the where clause?

  • As mentioned above, a simple in the WHERE clause should do this.

    This sounds like some test question or interview question. We are happy to help, but we want to see you do some work, show some effort. Take a basic table.

    create table mytable ( fieldA int, fieldB int)

    go

    insert mytable select 1, 1

    insert mytable select 2, 2

    insert mytable select 1, 2

    Write a query to find the row that doesn't match.

  • Hi,

    Thanks, i done it in where clause,

    as where cloumn a <> column b.

    i dont know what i was thinking when posting the query, may be just one of those moments :alien:. thanks .

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

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