Howdy folks.
(using mySQL 5.x as database)
This is a tad embarrassing, I've got my main table that I need to get info from two supporting tables. It seems to return ok, but I want all records from the main, and 1 each from the supporting tables.
tblCustomer is the main table
tblHistory returns all matching records for the LeadID instead of just the top one.
tblSalesPerson would only have one match anyway.
What am I missing to only return one matching from tblHistory?
Thank you in advance.
Stuart
(using mySQL 5.x as database)
This is a tad embarrassing, I've got my main table that I need to get info from two supporting tables. It seems to return ok, but I want all records from the main, and 1 each from the supporting tables.
tblCustomer is the main table
tblHistory returns all matching records for the LeadID instead of just the top one.
tblSalesPerson would only have one match anyway.
Code:
mySQL="Select tblCustomer.LeadID,tblCustomer.fldTitle,tblCustomer.fldFirstName,tblCustomer.fldLastName,tblCustomer.fldEmail, tblHistory.fldDate,tblHistory.fldType,tblHistory.fldFollowUp,tblHistory.fldFollowUpDate,tblHistory.fldFollowedUp,tblHistory.fldSalesPerson,tblSalesPerson.fldSalesSignature from tblCustomer "
mySQL=mySQL & " LEFT OUTER JOIN tblHistory ON (tblCustomer.leadID = tblHistory.fldLeadID)"
mySQL=mySQL & " LEFT OUTER JOIN tblSalesPerson ON (tblCustomer.fldSales1 = tblSalesPerson.fldUserName)"
mySQL=mySQL & " where (tblCustomer.fldEmail<>"" "" AND tblCustomer.fldEmail is NOT NULL) AND tblCustomer.fldOptOut=0 AND tblCustomer.fldNewsletter=0 order by tblCustomer.leadID asc, tblHistory.historyID desc Limit " & BDQuotes(request("txtAmount")) & ";"
set rs=Conn.execute(mySQL)
What am I missing to only return one matching from tblHistory?
Thank you in advance.
Stuart