Here is what I am at right now, but it does not return anything
select wp_users.user_nicename, wp_users.user_email, max(yearweek(wp_wpforo_posts.created)) as w
from LeBearCNC.wp_users, wp_wpforo_posts
where wp_users.ID = wp_wpforo_posts.userid
and not exists (select max(yearweek(wp_wpforo_posts.created)) where wp_users.ID = wp_wpforo_posts.userid) /*and yearweek(current_date()) - 12 < yearweek(wp_wpforo_posts.created))*/
group by wp_users.user_nicename, wp_users.user_email
order by w desc;
if I put the max(yearweek(wp_wpforo_posts.created)) in the where clause, I get an error "invalid use of group function"
Forgot to precise that wp_wpforo tables are for a forum plugin named wpForo
I managed to get what I want, using a temporary table, but I believe I should be able to bypass the need for this temporary table. I just don’t know how:
create temporary table if not exists lastpost as
(select wp_wpforo_posts.userid,max(date(wp_wpforo_posts.created)) as w
from wp_wpforo_posts
group by userid);
SELECT wp_users.display_name, wp_users.user_email, lastpost.w
from wp_users, lastpost
where lastpost.userid = wp_users.ID
and date_add(lastpost.w, interval 6 month) < date(current_date())
order by w desc;
Thanks for you help,
Bernard.
2
Answers
you can use subqueries as temporary tabels and notice is use standrd sql JOIN for my queries, as this is standrad nowadays
You could try to use this query