本文介绍了如何将AND操作放在sql server中的表的单个列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我正在尝试进行自定义搜索,我想搜索属于Atul和BaidyaNath的ID。表结构如下: id号名称 - - ---- 1 2 Atul 4 2 Atul 4 35 BaidyaNath 6 35 BaidyaNath 7 35 BaidyaNath 7 2 Atul 1 35 BaidyaNath 8 35 BaidyaNath 11 35 BaidyaNath 12 35 BaidyaNath 13 2 Atul 13 35 BaidyaNath 14 35 BaidyaNath 17 35 BaidyaNath 18 2 Atul 19 2 Atul 19 35 BaidyaNath 20 35 BaidyaNath 21 35 BaidyaNath 22 2 Atul 22 35 BaidyaNath 23 2 Atul 23 35 BaidyaNath 24 35 BaidyaNath 25 35 BaidyaNath 26 2 Atul 26 35 BaidyaNath 27 2 Atul 从上表中我想要属于的ids Atul 和 Baidyanath 。不是属于 Atul 或 Baidyanath 的ID。所以搜索到的ID应该是 4 ,7,1,13,19,22,23,26 。那么如何将一个AND操作放在一个表的一列中呢。 主要的问题是可以有n不。要搜索的名称。所以我们不能使用JOIN。 请建议我解决方法/方法。 提前谢谢。解决方案 尝试: SELECT id FROM MyTable WHERE 名称 IN ( ' BaidyaNath',' Atul') GROUP BY id HAVING COUNT(名称)> 1 Hi All, I am trying to do a customised search in which I want to search the ids which belong to both Atul and BaidyaNath. The table structure is as follows:id No. Name-- -- ----12Atul42Atul435BaidyaNath635BaidyaNath735BaidyaNath72Atul135BaidyaNath835BaidyaNath1135BaidyaNath1235BaidyaNath132Atul1335BaidyaNath1435BaidyaNath1735BaidyaNath182Atul192Atul1935BaidyaNath2035BaidyaNath2135BaidyaNath222Atul2235BaidyaNath232Atul2335BaidyaNath2435BaidyaNath2535BaidyaNath262Atul2635BaidyaNath272AtulFrom the above table I want the ids which belongs to both Atul and Baidyanath. Not the ids which belongs to either Atul or Baidyanath.So the searched ids should be 4,7,1,13,19,22,23,26. So how do I put a AND operation in a single column of a table.And the main problem is that there can be n no. of Names to be searched. So we cannot use JOIN.Kindly suggest me the solution/approach.Thanks in advance. 解决方案 这篇关于如何将AND操作放在sql server中的表的单个列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-17 09:51