从当前用户的表B中不存在的表A中选择[重复](Select from table A which does not exist in table B for Current user [duplicate])
这个问题在这里已经有了答案:
仅当值不存在时才返回行 2个答案我试图从表A中选择当前用户在表B中不存在的所有记录。 事实上,我有一个项目从表A获取横幅并显示给用户,然后我将这个活动插入表B(请参阅日志)我不喜欢向用户显示Repetitious横幅。 表A(横幅):
+-----------+ | bannerKey | +-----------+ | x7y3 | | r2s4 | | j6n2 | +-----------+表B(见日志):
+-----------++----------+ | bannerKey || userName | +-----------++----------+ | x7y3 || jack | | j6n2 || Chris | | r2s4 || Nicola | | j6n2 || Allen | | j6n2 || Nicola | +-----------++----------+那么,我如何从表A中获取当前用户的记录,当前用户,以前没有看到这个帖子?
This question already has an answer here:
Return row only if value doesn't exist 2 answersI'm trying to Select all records from table A which does not exist in table B for Current user. In fact, I have a project that get banner from table A and show to user, Then i insert this activity to table B (see log) That I whould not like show a Repetitious banner to a user. Table A (banners):
+-----------+ | bannerKey | +-----------+ | x7y3 | | r2s4 | | j6n2 | +-----------+Table B (see log):
+-----------++----------+ | bannerKey || userName | +-----------++----------+ | x7y3 || jack | | j6n2 || Chris | | r2s4 || Nicola | | j6n2 || Allen | | j6n2 || Nicola | +-----------++----------+So, How can i get a record from table A for current user that The current user, don't see this post in past?
最满意答案
尝试这个:
select * from banners a where not exists ( select 1 from table2 b where username = 'currentusername' -- substitute username here and a.bannerKey = b.bannerKey )Try this:
select * from banners a where not exists ( select 1 from table2 b where username = 'currentusername' -- substitute username here and a.bannerKey = b.bannerKey )更多推荐
发布评论