1
yangqi 2013-10-20 12:08:53 +08:00 1
SELECT id FROM channel WHERE channel_id IN ( SELECT channel_id FROM follow WHERE user_id != 'xxx' )
|
2
zxy 2013-10-20 12:17:09 +08:00 1
很久没写了,不知对错,还望指正
1、若channel_id 不重复,应该可以用这个 select * from channel where channel_id in (select chnnel_id from follow where user_id <>'xxx') 2、若channel_id 重复,改为 select * from channel where channel_id in (select chnnel_id from follow where channel_id not in (select channel_id from follow where user_id ='xxx') |
3
yangqi 2013-10-20 12:52:42 +08:00 1
读了N遍终于看懂楼主的意思了, 你给的步骤太复杂了,
直接 SELECT id FROM channel WHERE channel_id NOT IN ( SELECT channel_id FROM follow WHERE user_id = 'xxx' ) |
4
thinkif 2013-10-20 13:09:04 +08:00 1
select id, name, created from channel where exists(select 1 from follow where follow.channel_id = channel.id and user_id<>'xxx')
用 exists 比 In 快些 |