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 = 'me@example.com')) <= 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 = 'me@example.com' 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 me@example.com.
There could be many rows in the orders table with their email fields as me@example.com. I just want to find out all of these rows with email fields equals me@example.com that have datepurchased less than or equals one.
How should I phrase my SQL to achieve this?
There’s no need for a subquery in this case. Simply: