aspfantom
12-08-2004, 03:24 AM
I'm having trouble creating a query from multiple tables where the Primary Keys are the same. I'm trying to get both recordsets when the PK's match.
Here's my code:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
FilePath = Server.MapPath("2004.mdb")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath & ";"
set rs=Server.CreateObject("adodb.Recordset")
sql = "SELECT DatabaseFields.FirstName, DatabaseFields.LastName, Totals.SSN, Totals.LastName, Totals.PayoutTotal, Totals.FeeTotal, Totals.CRATotal"
sql = sql & " FROM DatabaseFields INNER JOIN Totals ON (DatabaseFields.SSN = Totals.SSN) AND (DatabaseFields.LastName = Totals.LastName);
rs.open sqlstmt, conn
If rs.eof then
response.write "<center>There are no records in the database"
response.write "<br>Please check back later</center>"
Else
%>
My trouble starts at the "INNER JOIN" AND "WHERE" statements
If I've made any other mistakes, corrections would be appreciated.
Someone PLEASE lead me in the right direction!!
Thanks in Advance!!
Here's my code:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
FilePath = Server.MapPath("2004.mdb")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath & ";"
set rs=Server.CreateObject("adodb.Recordset")
sql = "SELECT DatabaseFields.FirstName, DatabaseFields.LastName, Totals.SSN, Totals.LastName, Totals.PayoutTotal, Totals.FeeTotal, Totals.CRATotal"
sql = sql & " FROM DatabaseFields INNER JOIN Totals ON (DatabaseFields.SSN = Totals.SSN) AND (DatabaseFields.LastName = Totals.LastName);
rs.open sqlstmt, conn
If rs.eof then
response.write "<center>There are no records in the database"
response.write "<br>Please check back later</center>"
Else
%>
My trouble starts at the "INNER JOIN" AND "WHERE" statements
If I've made any other mistakes, corrections would be appreciated.
Someone PLEASE lead me in the right direction!!
Thanks in Advance!!