我有一个简单的查询但实际上不知道。我需要来自where
子句中的子查询的结果:
SELECT u.*,(SELECT COUNT(ur_id) FROM #__user_relation WHERE (uid1=u.u_id AND
uid2='#me') or (uid2=u.u_id AND uid1='#me')) as count FROM #__user as u WHERE
u.u_id!='me' AND count=0
Unknown column 'count' in 'where clause'
答案 0 :(得分:0)
SELECT u.*,(
SELECT COUNT(ur_id)
FROM #__user_relation
WHERE (uid1=u.u_id AND uid2='#me') or (uid2=u.u_id AND uid1='#me')) as count
FROM #__user as u
WHERE u.u_id!='me' **having count=0**