有用户活动记录表activity和好友表mem_friends
现在要找出用户自己和好友的活动记录sql语句我是这样写,但show processlist 有时会显示sending data..,网页就会卡住 有时又不会 是不是sql语句有问题?select * from activity where author='$u_id' or author in (select client_name from mem_friends where main_name='$u_id' and client_name!='$u_id' and isok='yes')
现在要找出用户自己和好友的活动记录sql语句我是这样写,但show processlist 有时会显示sending data..,网页就会卡住 有时又不会 是不是sql语句有问题?select * from activity where author='$u_id' or author in (select client_name from mem_friends where main_name='$u_id' and client_name!='$u_id' and isok='yes')
select * from activity where author in (自己的id和friends的id);
'截至2011-07-18 17:38:02 用户结帖率0.00%
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html8、如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖
mem_friends:main_name client_name isok 上建立复合索引,
将OR->UNION ALL
不好意思 看得不是很明白 要怎样union all?
union all
select * from activity a inner join mem_friends b
on a.author=b.client_name
where main_name='$u_id' and client_name!='$u_id' and isok='yes'
好像不行哦提示:
#1222 - The used SELECT statements have a different number of columns
union all的两个select要列数一样吧?
...
union
all-- 没必要重复的吧select a.*
...