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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Efficient batch update/synchronization

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all, I'm a newbie, and I was wondering if there's a more efficient way to accomplish the update the SQL query below performs:

UPDATE mls
SET bath_level =
(SELECT bath_level
FROM idxmls1
WHERE id = [mls].[id]), class = 1, list_price =
(SELECT list_price
FROM idxmls1
WHERE id = [mls].[id])
WHERE (lister_office_name NOT LIKE ' % spencer % ') AND (lister_office_name NOT LIKE ' % hughes % ') AND (town IN
(SELECT town
FROM areas))
 
Use a JOIN query. The following will be much more efficient.

UPDATE mls SET
bath_level = i.bath_level,
class = 1,
list_price = i.list_price
FROM mls m
JOIN idxmls1 i
m.id = i.id

WHERE (lister_office_name NOT LIKE ' % spencer % ')
AND (lister_office_name NOT LIKE ' % hughes % ')
--The code doesn't indicate which table
--has the columntown so I assumed mls
AND Exists (SELECT * FROM areas Where town=m.town) Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top