我有两张桌子。
- fbuser(facebook_ID, date_of_birth) - facebook_id 是主键
- wall(wall_ID, facebook_ID, public_view) - facebook_id 是外键
我想查找将墙设置为公开视图且年龄超过 24 岁的用户?
Select f.facebook_ID from fbuser f, wall w
WHERE
(w.public_view='y')
AND
(f.facebook_ID=w.facebook_ID)
AND
(select FLOOR( MONTHS_BETWEEN( CURRENT_DATE, f.date_of_birth ) / 12 )
as person_age from fbuser where person_age >=24;