Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query question

Status
Not open for further replies.

shannanl

IS-IT--Management
Apr 24, 2003
1,071
US
I have two tables in my db.

Table 1 Table 2
LastName LastName
FirstName FirstName
Account Account

Table 2 is updated every 10 minutes. Table one is updated by a user randomly during the day. The user enters the last and first name in table 1 and the account field is left null. Table 2 is updated by a link from somewhere else but when it updates it will have the account number filled in. I would like to compare Table 1 and 2 after table 2 updates and have it automatically update table 1 field account number if it finds a match between the last and first names in each table. I just need help with the query.

Is this possible? If so how would I go about it?

Thanks in advance for the help.

Shannan
 
If it's in a MS SQL db then creat a trigger for when table2 gets updates. Then you can use the insert command after you find the unmatched entries in table 1. ( You do this by using a sub query that searches for account where not in select account from table 2)
 
You don't want to use an INSERT statement, that will just add new rows. Use an UPDATE to add a value to the existing row where the names match and the account is null in TABLE 1.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
sometimes triggers may slow down operations.

another way out could be to maybe run a job once every X minutes that can update the data.

However i do have a question. why 2 tables???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top