I need some help with a complicated SQL Query can someone help me write something like this?
Im actually using this in an .asp webpage to access my db so if someone knows how to write this in asp sql it would be most handy for my application. TY in advance.
Code:
<%
if DetectedButton = "Manually Match Requests" then
'Prep the database to be accessed
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/path to my.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
SQL = 'Select * FROM tbl_Customers WHERE
tbl_Customers.[MatchedTo] = NULL
Then Find 3
Select * FROM tbl_Service_Providers WHERE
tbl_Service_Providers.[%CoverageArea%] = tbl_Customers.[zip] and
tbl_Service_Providers.[%ServicesProvided%] = tbl_Customers.[ServiceType] and
tbl_Service_Providers.[LastMatchedDate] is oldest Date
Then
Insert 3 found tbl_Service_Providers.[ProviderID] and tbl_Service_Providers.[ServiceCompanyName] into tbl_Customers.[MatchedTo] seperated by "," between each of the three
Update each of last three selected tbl_Service_Providers.[LastMtchedDate] to Now()
End If
%>