PDA

View Full Version : MySQL select


dodjer42
10-25-2008, 12:26 AM
I'm using the vbulletin db classes.

I want to select field19 from users where users is member of group 15 and last activity was within 30 days.

Anybody know how to do this?

--------------- Added 1224909756 at 1224909756 ---------------

Got this far:

SELECT user.userid, userfield.field19
FROM user
INNER JOIN userfield ON user.userid = userfield.userid
WHERE (
user.membergroupids LIKE 15
OR user.usergroupid LIKE 15
)
AND userfield.field19 != '';

Just have to work out how to do the dates.

Eikinskjaldi
10-26-2008, 09:40 PM
I'm using the vbulletin db classes.

I want to select field19 from users where users is member of group 15 and last activity was within 30 days.


select u.userid, uf.field19
from user u
join userfield uf using (userid)
where find_in_set('15',u.membergroupids) > 0
and to_days(now()) - to_days(from_unixtime(u.lastactivity)) <= 30