SELECT id FROM channel WHERE channel_id IN ( SELECT channel_id FROM follow WHERE user_id != 'xxx' )
zxy
2013-10-20 12:17:09 +08:00
很久没写了,不知对错,还望指正 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')
yangqi
2013-10-20 12:52:42 +08:00
读了N遍终于看懂楼主的意思了, 你给的步骤太复杂了,
直接 SELECT id FROM channel WHERE channel_id NOT IN ( SELECT channel_id FROM follow WHERE user_id = 'xxx' )
thinkif
2013-10-20 13:09:04 +08:00
select id, name, created from channel where exists(select 1 from follow where follow.channel_id = channel.id and user_id<>'xxx')
用 exists 比 In 快些
第 1 页 / 共 1 页
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。