DataView.RowFilter,多个列上的多个可能值

发布于 2024-07-13 21:13:31 字数 363 浏览 4 评论 0原文

我有一个数据视图,其中有趣的列是长度、高度、颜色 1 和颜色 2,其中颜色 1 和颜色 2 可以是黄色、红色、蓝色、黑色、白色或绿色中的任何一种。 应用过滤器以获取具有一定长度和高度但仅具有红色、蓝色和绿色颜色的行的最佳方法是什么?

当可能的颜色增加时,下面的过滤器感觉有点“难看”:

"length > 10 AND height > 10 AND (color1 = 'red' OR color1 = 'blue' OR color1 = 'green') AND ( color2 = 'red' OR color2 = 'blue' OR color2 = 'green')"

或者这是唯一/最简单的方法?

I have a dataview where the interresting columns are length, height, color1, and color2 where color1 and color2 can be any of yellow, red, blue, black, white, or green. What is the best way to apply a filter where I get the rows with a certain length and height but with only the colors red, blue, and green?

The filter below feels a bit 'ugly' when the possible colors grow:

"length > 10 AND height > 10 AND (color1 = 'red' OR color1 = 'blue' OR color1 = 'green') AND (color2 = 'red' OR color2 = 'blue' OR color2 = 'green')"

Or is this the only/simplest way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清泪尽 2024-07-20 21:13:31

不幸的是,这是“SQL 样式”查询的本质:)

IN 子句可能会使该查询更简单:

"length > 10 AND height > 10 AND color1 IN ('red', 'blue', 'green') AND color2 IN ('red', 'blue', 'green')"

Unfortunately, this is the nature of "SQL style" queries :)

The IN clause might make that query simpler:

"length > 10 AND height > 10 AND color1 IN ('red', 'blue', 'green') AND color2 IN ('red', 'blue', 'green')"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文