Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select to compare two tables
Message
From
29/01/2022 20:02:04
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01683376
Message ID:
01683383
Views:
27
OK, I'm a little confused then. You initially said, "...just those rows that exist in one table but do not exist in another table."

I took that to mean that a specific ID number was in Table A but not Table B. I guess maybe it boils down to, what is meant by "exists" in this context of the data?

OK, if a single ID value (like 789) could exist as many rows in table A but not B....then you'd need to do a SELECT DISTINCT

But if that doesn't help, then maybe I'm missing the question.


>Again, thank you. The first SQL won't work since the value in ID_NUMBER could be the same for many rows. But some other columns are different. I will try your second approach. Although I thought that the SQL Select would have the actual column names.
>
>I am trying to figure out an example and right now I can't figure it ou.
>
>>Here's the simplest way....if all you want are the ID numbers in Table A that don't exist in Table B...
>>
>>SELECT ID_Number from TABLEA
>>EXCEPT
>>SELECT ID_Number from TABLEB
>>
>>Now, if you want "all the columns" from table A, you can do this...
>>
>>SELECT * FROM TABLEA WHERE ID_NUMBER IN
>> (SELECT ID_Number from TABLEA INSIDE_A
>> EXCEPT
>> SELECT ID_Number from TABLEB INSIDE_B )
>>
>>Now....I'm assuming you don't have any NULL values for ID_Number (which, if it's a key identifier, you shouldn't).
>>If you somehow do, you'd need to put a few IF NOT NULL statements....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform