SQL Returning too many records?

Results 1 to 2 of 2

Thread: SQL Returning too many records?

  1. #1
    Join Date
    Dec 1969

    Default SQL Returning too many records?

    This SQL should only return records for that tblContacts.NextAction are &#060;= Date(), yet it returns all dates? Before and after Date(). Any ideas? <BR><BR>Dim dtDueDate<BR>dtDueDate = Date()<BR><BR>strSQL ="SELECT tblContacts.*, tblContacts.DealerId, <BR>tblContacts.UserId, tblContacts.NextActionDue, <BR>tblContacts.NextAction, tblUsers.FirstName AS UserFirstName, tblUsers.LastName AS UserLastName, tblDeals.DealDate <BR>FROM tblDeals <BR>INNER JOIN (tblUsers RIGHT JOIN tblContacts ON tblUsers.UserId = tblContacts.UserId) <BR>ON tblDeals.ContactId = tblContacts.ContactId <BR>WHERE tblContacts.MakeInactive = &#039;NO&#039; AND tblContacts.DealerId = "& Session("DealerId") &" <BR>AND tblContacts.NextActionDue = #" & dtDueDate & "# AND tblContacts.MarkSold = &#039;YES&#039; <BR>AND tblContacts.NextAction = &#039;Thank You Letter&#039; OR tblContacts.NextAction = &#039;30 Day Letter&#039; " <BR>OR tblContacts.NextAction = &#039;6 Month Letter&#039; OR tblContacts.NextAction = &#039;1 Year Letter&#039; " <BR>ORDER BY tblContacts.NextAction, tblContacts.UserId ASC "<BR><BR>Everything works great except the date field?<BR>Thanks in advance, David<BR>

  2. #2
    Join Date
    Dec 1969

    Default it's all about ()

    You have to put the correct () in the AND and OR statements. Just like the same you do in math.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts