从当前用户的表B中不存在的表A中选择[重复](Select from table A which does not exist in table B for Current user [duplica

编程入门 行业动态 更新时间:2024-10-16 00:18:23
从当前用户的表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 answers

I'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 )

更多推荐

本文发布于:2023-07-07 21:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1068430.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   用户   Select   table   duplicate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!