Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24
  1. #11
    Join Date
    Jan 2012
    Posts
    488
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    Quote Originally Posted by philip937 View Post
    The query I need wants to select customers that haven't made a purchase and group by date based on when they signed up. Basically the two elements I posted earlier in this thread need to be combined with another join statement?


    Code:
    Select
      customers_info.customers_info_date_account_created,
      customers.customers_lastname,
      customers.customers_firstname,
      orders.date_purchased
    From
      customers_info Inner Join
      customers On customers_info.customers_info_id = customers.customers_id
      Inner Join
      orders On orders.customers_id = customers.customers_id
    Where
      orders.date_purchased <= Date(Date_Sub(Now(), Interval 14 Day)) And
      customers_info.customers_info_date_account_created <= Date(Date_Sub(Now(),
      Interval 14 Day))
    Group By
      customers_info.customers_info_date_account_created

  2. #12
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    nearly. i think this is what im after, need to test later.

    Select
    customers_info.customers_info_date_account_created,
    customers.customers_lastname,
    customers.customers_firstname,
    orders.date_purchased
    From
    customers_info Inner Join
    customers On customers_info.customers_info_id = customers.customers_id
    Inner Join
    orders On orders.customers_id = customers.customers_id
    Where
    orders.date_purchased IS NULL AND
    customers_info.customers_info_date_account_created BETWEEN (NOW() - INTERVAL 14 DAY) AND (NOW() - INTERVAL 7 DAY)

    thanks for the pointers :)
    Phil Rogers
    A problem shared is a problem solved.

  3. #13
    Join Date
    Jan 2012
    Posts
    488
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    Quote Originally Posted by philip937 View Post
    nearly. i think this is what im after, need to test later.

    Select
    customers_info.customers_info_date_account_created,
    customers.customers_lastname,
    customers.customers_firstname,
    orders.date_purchased
    From
    customers_info Inner Join
    customers On customers_info.customers_info_id = customers.customers_id
    Inner Join
    orders On orders.customers_id = customers.customers_id
    Where
    orders.date_purchased IS NULL AND
    customers_info.customers_info_date_account_created BETWEEN (NOW() - INTERVAL 14 DAY) AND (NOW() - INTERVAL 7 DAY)

    thanks for the pointers :)
    The problem is 'orders.date_ordered' will not be null, because only if they ordered is there an entry in the orders table.

    I think you need to look at customers.customers_id and compare that with orders.customers_id and if they don't exist in orders table, get that list.

  4. #14
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    The problem is 'orders.date_ordered' will not be null, because only if they ordered is there an entry in the orders table.

    I think you need to look at customers.customers_id and compare that with orders.customers_id and if they don't exist in orders table, get that list.
    exactly so we are saying if it returns NULL then they havent ordered, therefore we want their email address to email them?
    that is taken directly from the default value
    'Send email to customers that havent yet made a purchase'

    so this is what we want it to do.

    select all customers that registered between the period -14 days - -7 days ago that havent yet ordered.
    Phil Rogers
    A problem shared is a problem solved.

  5. #15
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    this is the default entry in the 1.5.1 install:

    SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL

    this returns all customers that have not yet made a purchase.

    my objective was exacly this but to only return customers that registered 1 week ago i.e between -14 days and -7 days period.
    Phil Rogers
    A problem shared is a problem solved.

  6. #16
    Join Date
    Jan 2012
    Posts
    488
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    Quote Originally Posted by philip937 View Post
    this is the default entry in the 1.5.1 install:

    SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL

    this returns all customers that have not yet made a purchase.

    my objective was exacly this but to only return customers that registered 1 week ago i.e between -14 days and -7 days period.
    1.5 is different then, you need customers_info table and 'date_purchased' is NULL returns no customers, because the field is not NULL, the whole record won't exist in the orders table.

  7. #17
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    im confused now..

    if the default query works currently to call all the customers, then doing the same thing and adding the table join to only select customers that registered between those dates whats the problem?
    Phil Rogers
    A problem shared is a problem solved.

  8. #18
    Join Date
    Jan 2012
    Posts
    488
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    Quote Originally Posted by philip937 View Post
    im confused now..

    if the default query works currently to call all the customers, then doing the same thing and adding the table join to only select customers that registered between those dates whats the problem?
    They aren't a 'customer' with 'date_ordered' entry if they have never placed an order.

    You will need a nested select statement in your WHERE/WHERE NOT EXIST clause to determine that the customers_id is in the customer table but NOT in the orders table.

  9. #19
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    Assignable it's testing it against the table join not the actual table so the entries will be there but the fields will be null against customers with no orders..?
    Phil Rogers
    A problem shared is a problem solved.

  10. #20
    Join Date
    Jan 2012
    Posts
    488
    Plugin Contributions
    0

    Default Re: Send Email to Customers Question

    That is not what I saw when testing for null. It returned no customer_id records.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v139h Send email to all customers with header and footer question?
    By dustbowl in forum General Questions
    Replies: 2
    Last Post: 31 Jul 2012, 12:43 PM
  2. Send Email To Customers - linebreaks
    By dmagic in forum General Questions
    Replies: 0
    Last Post: 12 Mar 2011, 12:34 PM
  3. Send Email To Customers
    By FatGuyinAZ in forum General Questions
    Replies: 5
    Last Post: 1 Dec 2010, 03:09 AM
  4. Send scheduled email to customers???
    By hifipj in forum General Questions
    Replies: 2
    Last Post: 16 Oct 2007, 02:39 PM
  5. Cannot send customers email
    By bhfruitcakeco in forum General Questions
    Replies: 2
    Last Post: 21 Dec 2006, 09:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR