i really need some help with my sql, i m very noob in this, so hope you guys can help.
my table look like this:
+-------------------------------+ | Products | +-------------------------------+ | users | Product | Date | | 1 | A | 2022-09-10 | | 1 | A | 2022-09-23 | | 1 | B | 2022-09-10 | | 2 | A | 2022-09-10 | | 2 | C | 2022-09-10 | +-------------------------------+
I need to find next upcoming date from specific user and from a specific product.
I tried this, but it wont work:
SELECT `date` FROM `products` WHERE `users`='1' & `Product`='A' & date(`date`) = (select min(date(`date`)) from products where date(`date`) > date(now()) )
Hope you can help me guys
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
[Upcoming date + Specific user and product]
SELECT *
FROM products
WHERE users=1 AND
Product='A' AND
date(`Date`) > date(now())
LIMIT 1;
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0