Jump to content

Statement Comparing dates then display certain records.


vmicchia

Recommended Posts

So what I want to do is select the customer info  from an order table where their total is less than 30 but more than 0 and then see if they do or do not have another order placed at a later date from the results of the first search and then display the people who have not made an order at that later date. I really have no idea where to start or if this is even possible. If anyone could link me to some tutorial or help me out it would be very much appreciated.

Link to comment
Share on other sites

Ok Then I will try to expand. I Have a table with information for orders(firstname, lastname, order_id, total, notes, timestamp(unix), phone, email, status). Now what I want to do is have a sql statement(s) that first check for orders that total $30 or less. Once that is done I want to check if there has been an order places since the order of less than thirty dollars. then display people who have not made an order since that order of $30.

 

I know how to check for the order total but once I need to check if more orders were placed on multiple records and then compare the dates I get lost.

 

Any help is much appreciated.

Link to comment
Share on other sites

I guess where my problem comes in is that after

 

$sql = "SELECT * FROM orders WHERE total < 30";
        $result = mysql_query($sql);

 

A: Do i need to fetch the array or can I somehow use that just as the result?

 

B: How to I then Find if these customers(comparing by email) have a more recent order? And then display the customers that do not?

 

I'm unsure on how to use the arrays that are returned to accomplish this. I think it would have to be a while loop but not sure how to execute. Any help is much appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.