deuxk Posted May 5, 2014 Share Posted May 5, 2014 Hi, I'd get to do a join query with 3 (sometimes 2). Here is the structure of my 3 tables in question: items> id, cat, subcategory, created status> itemId, level Modify> id, itemId, date, type Here's my query so far: SELECT i.id, i.userId FROM items i LEFT OUTER JOIN statut s ON i.id = s.itemId WHERE CASE WHEN ( SELECT m.date FROM modification m WHERE m.itemId = i.id ORDER BY m.date DESC LIMIT 1 ) IS NULL THEN i.created END > DATE_SUB(NOW(), INTERVAL 90 DAY) AND s. LEVEL = 1 I would like to get a look at what the last change add and see if it has been over 90 days. In case no change was made compared with the creation date of the item. He that can strongly that there are several changes to a single item so it should really checked with the last added in case there.Thank you for your help! Quote Link to comment https://forums.phpfreaks.com/topic/288256-clear-items-created-or-not-change-in-the-last-90-days/ Share on other sites More sharing options...
Barand Posted May 5, 2014 Share Posted May 5, 2014 The only bit I understood was the title "items created or not change in the last 90 days" Try SELECT i.id , i.userId FROM items i LEFT JOIN modify m ON m.itemId = i.id AND m.date > CURDATE() - INTERVAL 90 DAY WHERE m.date IS NULL OR i.created > CURDATE() - INTERVAL 90 DAY Quote Link to comment https://forums.phpfreaks.com/topic/288256-clear-items-created-or-not-change-in-the-last-90-days/#findComment-1478277 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.