sorry about the title. i dont know how to say this in a nut shell.
i have a query that gives results of previous orders for customers. but it will only give the most recent.
what i am trying to do is generate a mailing list reminding customers of their previous orders. asking for feedback, if they are ready to place another one etc. the problem i have is that it is a salon. so customers can have future bookings. so i would like to deduct from the mailing list the items that the customer has in the future.
eg. a customer ordered item 1 and item 2 in feb 2010. the customer has already booked for item 1 again in june but not item 2. so i am wanting to have a query that will give me the most recent item that a customer does not already have booked in.
the sql i already have is below but it is missing the most crucial minus the future orders.
now im not sure if i am going to have to do this in this query or use multiple queries to compile the data and get the results i want.
thanks for reading this and if i have not made much sense just let me know because i found it hard to explain. i know what i want to do in my head and hopefully you guys also do now.
i have a query that gives results of previous orders for customers. but it will only give the most recent.
what i am trying to do is generate a mailing list reminding customers of their previous orders. asking for feedback, if they are ready to place another one etc. the problem i have is that it is a salon. so customers can have future bookings. so i would like to deduct from the mailing list the items that the customer has in the future.
eg. a customer ordered item 1 and item 2 in feb 2010. the customer has already booked for item 1 again in june but not item 2. so i am wanting to have a query that will give me the most recent item that a customer does not already have booked in.
the sql i already have is below but it is missing the most crucial minus the future orders.
PHP:
SELECT tblOrders.ClientDetailsID, tblClientDetails.FirstName, tblClientDetails.Surname, Last(tblOrdersItems.OrdersItemsID) AS LastOfOrdersItemsID, Last(tblItems.Items) AS LastOfItems, Last(tblOrders.OrderDate) AS LastOfOrderDate, Last(tblCategories.Catergorie) AS LastOfCatergorie, tblOrderItemsType.Type, Last(tblItems.available) AS LastOfavailable, Last(tblItems.ItemsID) AS LastOfItemsID, tblClientDetails.EmailAddress, tblOrdersItems.EmailPurchaseReminder, Last(tblEmployeeList.FirstName) AS LastOfFirstName INTO tblEmailPurchaseReminders
FROM tblOrderItemsType INNER JOIN (tblClientDetails INNER JOIN (tblCategories INNER JOIN (tblEmployeeList INNER JOIN (tblItems INNER JOIN (tblOrders INNER JOIN tblOrdersItems ON tblOrders.OrderID = tblOrdersItems.OrderID) ON tblItems.ItemsID = tblOrdersItems.[ItemsID]) ON tblEmployeeList.EmployeeListID = tblOrdersItems.Employee) ON tblCategories.CategoriesID = tblItems.CategoriesID) ON tblClientDetails.ClientDetailsID = tblOrders.ClientDetailsID) ON tblOrderItemsType.OrderItemsTypeID = tblItems.OrdersItemsTypeID
GROUP BY tblOrders.ClientDetailsID, tblClientDetails.FirstName, tblClientDetails.Surname, tblOrderItemsType.Type, tblClientDetails.EmailAddress, tblOrdersItems.EmailPurchaseReminder
HAVING (((Last(tblOrders.OrderDate)) Between DateAdd("m",-3,Date()) And DateAdd('m',-6,Date())) AND ((tblOrderItemsType.Type)="Retail") AND ((Last(tblItems.available))=Yes) AND ((tblClientDetails.EmailAddress) Is Not Null) AND ((tblOrdersItems.EmailPurchaseReminder)=No));
now im not sure if i am going to have to do this in this query or use multiple queries to compile the data and get the results i want.
thanks for reading this and if i have not made much sense just let me know because i found it hard to explain. i know what i want to do in my head and hopefully you guys also do now.