Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Combine multiple sql calls into 1
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Combine multiple sql calls into 1

 Post Reply Post Reply
Author
rx7tt View Drop Down
Groupie
Groupie


Joined: 25 October 2004
Location: United States
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote rx7tt Quote  Post ReplyReply Direct Link To This Post Topic: Combine multiple sql calls into 1
    Posted: 15 January 2006 at 6:25pm
I have an old app that I'm trying to recode and improve performance.

From the start it makes three seperate calls to a db, checks to see if the record exists, if it doesn't it adds it, then takes the data from all three and inserts it into a final call.

Here is a quick example of the script

Select * from table1 where id = " & tempVariable
If Not RS.EOF Then
  strTable1 = RS("SomeRec")
Else
  RS.ADDNEW
  RS("SomeRec") = tempRec1
  RS.UPDATE
  RS.Requery
  strTable1 = RS("SomeRec")
End If
RS.CLOSE

Select * from table2 where id =2
If Not RS.EOF Then
  strTable2 = RS("SomeRec")
Else
  RS.ADDNEW
  RS("SomeRec") = tempRec2
  RS.UPDATE
  RS.Requery
  strTable2 = RS("SomeRec")
End If
RS.CLOSE

Select * from table3 where id =3
If Not RS.EOF Then
  strTable3 = RS("SomeRec")
Else
  RS.ADDNEW
  RS("SomeRec") = tempRec3
  RS.UPDATE
  RS.Requery
  strTable3 = RS("SomeRec")
End If
RS.CLOSE

INSERT INTO Table4 (Table1, Table2, Table3) VALUES ('" & strTable1 & "', '" & strTable2 & "', '" & strTable3 & "'


These is probably an easy solution however I don't know where to start. Any help or ideas will be greatly appreciated.
Thanks
-Scott


Edited by rx7tt - 15 January 2006 at 6:27pm
Mobile Gear.biz-Ringtones, games, videos, links and more...
Wireless Forums
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.