Question : How do i find the difference between 2 Database tables

I would like to find the difference in records i have between two tables. "Table A", is constantly being updated with new records, "Table B" holds sub information of "Table A". They are connected thru the InternalID. Basically i need the SQL syntax to find the records in Table A that are not in Table B. Hope this makes sense. I have written some pseudo code below to try to represent what i need. I konw it is wrong, but can anyone help me out here?

Table A is tbl_FS_Items_Basic
Table B is tbl_FS_Items_US
Code Snippet:
1:
$query_rsItemsOptions = "SELECT tbl_FS_Items_Basic.InternalID, tbl_FS_Items_Basic.Name, tbl_FS_Items_US.InternalID FROM tbl_FS_Items_Basic, tbl_FS_Items_US WHERE tbl_FS_Items_Basic.InternalID != tbl_FS_Items_US.InternalID ";
Open in New Window Select All

Answer : How do i find the difference between 2 Database tables

The above query is fine too, but the left join is more efficient and is handled better than the NOT IN clause by the SQL Optimizer..

If the number of rows in Table A and Table B are significant (say more than 10000 rows), you will see that the left join will be much much quicker..
Random Solutions  
 
programming4us programming4us