View Single Post
  #3 (permalink)  
Old March 21st, 2007, 10:29 AM
pallone pallone is offline
Friend of Wrox
Points: 1,243, Level: 13
Points: 1,243, Level: 13 Points: 1,243, Level: 13 Points: 1,243, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: , , United Kingdom.
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Hi Vijay G,

Thanks for your reply.

CompanyCompare is the 3rd table that will have the old and new records but no repetition. If the old values are different in table 1 then it will need to be updated as well. Basically, I have two tables with company info in them. However, the ID of both tables do not match. If they matched the code I wrote above would work.

So, I will have to read the Name field of both tables and check if the string is equal or have some similarities. If they do, then I will have to get the ID of table 1 plus ID from table 2 and insert them to the CompanyCompare table together with the updated MaxValue from Table 1.



Table 1
+------------+----------+------+-----+
| ID | Name | MaxValue |
+------------+----------+------+-----+
| 1 | Wilbey sx| 2000 |
+------------+----------+------+-----+
| 2 | Aimor sp | 10000 |
+------------+----------+------+-----+

Table 2
+------------+----------+------+-----+
| ID | Name | MaxValue |
+------------+----------+------+-----+
| 37 | Wilbey sx| 6000 |
+------------+----------+------+-----+
| 104 | Aimor | 10000 |
+------------+----------+------+-----+

After running the sql script the CompanyCompare table will have to look sothing like this:

CompanyCompare Table

+------------+----------+------------+-----------------------+
| IDTab1 | IDTab2 | Name | MaxValue |
+------------+----------+------------+-----------------------+
| 1 | 37 | Wilbey sx | 2000 |
+------------+----------+------------+-----------------------+
| 2 | 104 | Aimor sp | 10000 |
+------------+----------+------------+-----------------------+
| 2 | 104 | Aimor | 10000 |
+------------+----------+------------+-----------------------+
| | | | |
+------------+----------+------------+-----------------------+

Because the first row of both tables have the same string value i.e. Wilbey sx, I have to copy the IDs from both tables to the CompanyCompare and also the Name and MaxValue fields from table 1 since table 1 will be the table with the most recent values.

However, since the string values of the Name columns in the second row for both tables do not match but have some similarities, I will have to add both records to the CompareTable so that I can compare them later.

Hope it is clearer now.

Cheer

CPall
Reply With Quote