devxlogo

Comparing Columns from Different Tables

Comparing Columns from Different Tables

Question:
I have a problem comparing columns from different tables. I tried:

 SELECT tblThumBereinigt.Nummer, dbo_BABEWERTUNG.BANUMMERFROM dbo_BABEWERTUNG, tblThumBereinigtWHERE (((dbo_BABEWERTUNG.BANUMMER)<>[tblThumBereinigt].[Nummer]));

but this does not give me what I want. How can I compare different tables with an exclusive condition?

Answer:
Try this:

 select * from information_schema.columns

That should give you a list of information about the columns in your database.

As a matter of form, though, doing the not-equals comparison here matches every row from the left-hand table to every row of the right-hand table, because each instance of number will NOT EQUAL any other, so you’ll wind up with a giant cross-join instead.

See also  Comparing different methods of testing your Infrastructure-as-Code
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist