I am tring to query a set of data from mySQL with the following SQL:
SELECT * FROM orders
WHERE datediff((now()), (SELECT datepurchased FROM orders WHERE email = '[email protected]')) <= 1
But the problem is I get the error that #1242 - Subquery returns more than 1 row because the statement SELECT datepurchased FROM orders WHERE email = '[email protected]' is returning more than one rows, which is perfectly correct.
The idea that I wanted is to select from the orders table such that the date difference between the current time and the datepurchased field is <=1 and that the email field is equals to [email protected].
There could be many rows in the orders table with their email fields as [email protected]. I just want to find out all of these rows with email fields equals [email protected] that have datepurchased less than or equals one.
How should I phrase my SQL to achieve this?