1
我有兩個表。計算年齡在內部查詢然後與值比較
- fbuser(facebook_ID,DATE_OF_BIRTH) - facebook_id是主鍵
- 牆(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;