根据子标签搜索所有类似的ID(Search for all similar ID's based on subids)

编程入门 行业动态 更新时间:2024-10-20 00:30:34
根据子标签搜索所有类似的ID(Search for all similar ID's based on subids)

如果其他列值被过滤,我想提取所有重复的ID。

例如:

ID Subid 100 99 100 91 100 12 200 32 200 33 200 34 200 35 300 88 300 87 300 86 400 78 400 74 400 73

如果我只想查询子ID 99,它应检查其ID,并显示具有该ID的所有行。 结果应该是

ID Subid 100 99 100 91 100 12

感谢您是否可以提供帮助。

关心沙拉

I would like to extract all the duplicate ID's if other column value is filtered.

ex:

ID Subid 100 99 100 91 100 12 200 32 200 33 200 34 200 35 300 88 300 87 300 86 400 78 400 74 400 73

If i want to query only for sub id 99, it should check its ID, and all the rows having that ID should display. Here the result should be

ID Subid 100 99 100 91 100 12

Appreciate if you could help.

Regards sharath

最满意答案

一个简单的条件可以做到这一点

select * from table1 where ID in (select id from table1 where subid = 99);

(或)将上面的子查询转换为self join

select t.* from table1 t join table1 t1 on t.ID = t1.ID where t1.subid = 99;

A simple where condition would do this

select * from table1 where ID in (select id from table1 where subid = 99);

(OR) convert above subquery to a self join

select t.* from table1 t join table1 t1 on t.ID = t1.ID where t1.subid = 99;

更多推荐

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

发布评论

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

>www.elefans.com

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