<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Query logic</title><link>https://community.appian.com/discussions/f/general/35209/query-logic</link><description>Hey all, 
 Please provide suggestions for below scenario 
 
 1st row is having a columv value &amp;#39;GE | SP |US&amp;#39; 
 2nd row is having column value &amp;#39;USA | CA&amp;#39; 
 
 I need to query the row which is having US or SP in it . I tried the approach of looping(US,SP</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Query logic</title><link>https://community.appian.com/thread/136727?ContentTypeID=1</link><pubDate>Wed, 12 Jun 2024 05:32:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7e813f4c-6dea-4ef6-99a9-505382db36aa</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Sorry, but the reason to change the design is NOT the query problem. The reason is, that it is against any best practices, and violating these creates the issue you are facing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query logic</title><link>https://community.appian.com/thread/136713?ContentTypeID=1</link><pubDate>Wed, 12 Jun 2024 03:02:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a19d1264-4905-4fce-8617-ddc9c73d95f3</guid><dc:creator>Yogi Patel</dc:creator><description>&lt;p&gt;&lt;span&gt;As suggested by &lt;a href="/members/stefanhelzle0001"&gt;Stefan Helzle&lt;/a&gt;&amp;nbsp;and &lt;a href="/members/mikes0011"&gt;Mike Schmitt&lt;/a&gt;&amp;nbsp;, you should change the database design if possible. If that option is not available, you can try the following query to get the desired result:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!queryEntity(
  entity: cons!YD_DT_DEMO,
  query: a!query(
    logicalExpression: a!queryLogicalExpression(
      operator: &amp;quot;OR&amp;quot;,
      filters: {
        a!queryFilter(
          field: &amp;quot;name&amp;quot;,
          operator: &amp;quot;in&amp;quot;,
          value: { &amp;quot;|US&amp;quot;, &amp;quot;|US|&amp;quot;, &amp;quot;US|&amp;quot; }
        ),
        a!queryFilter(
          field: &amp;quot;name&amp;quot;,
          operator: &amp;quot;in&amp;quot;,
          value: { &amp;quot;|SP&amp;quot;, &amp;quot;|SP|&amp;quot;, &amp;quot;SP|&amp;quot; }
        )
      }
    ),
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
  ),
  fetchTotalCount: false
)&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Note: You can write code to generate the value of in parameters { &amp;quot;|US&amp;quot;, &amp;quot;|US|&amp;quot;, &amp;quot;US|&amp;quot; }.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query logic</title><link>https://community.appian.com/thread/136705?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2024 19:46:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e1bf6536-6d5f-4a5e-97b6-8d9995a59efa</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This is a good example of why, whenever anyone is &lt;em&gt;&lt;strong&gt;forced&lt;/strong&gt;&lt;/em&gt; to store an array of data in a text column, i always recommend they &lt;em&gt;at least&lt;/em&gt; store it as JSON data.&amp;nbsp; In that manner there are enough delimiters to allow searching on exact substrings (since you&amp;#39;d be able to search on i.e. the exact string &amp;quot;US&amp;quot; including the quotes, eliminating the accidental inclusion of errant matches like &amp;quot;USA&amp;quot; in this case).&amp;nbsp; It also takes a lot of the &amp;quot;guesswork&amp;quot; out of parsing the stored contents back into an array (you don&amp;#39;t have to worry about writing your own parser and handling edge cases, since JSON takes care of most of that for you).&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/11/pastedimage1718135023408v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I guess my question for your case is, do you have alternative options availalbe like writing a View to pre-parse the values a little bit (i think you could probably split multiple values across the [" | "] string, then handle them better, and query from that), or perhaps create a new DB column that could store the same data but parsed into a more readable format?&amp;nbsp; (Or even a link table where you add an independent entry for each item in the original set?)&amp;nbsp; Because without a more deluxe solution like that, I&amp;#39;m not sure you&amp;#39;ll be able to solve all the corner cases you are likely to run into with your current set-up.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query logic</title><link>https://community.appian.com/thread/136702?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2024 19:18:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9f8b1987-5fd5-4406-ae55-1205228a79b0</guid><dc:creator>Vaishal</dc:creator><description>&lt;p&gt;Hi Stefan.&lt;/p&gt;
&lt;p&gt;Yeah i agree. Actually its a already existing view and i dont see any specific reason to store this way. We need to change the&amp;nbsp; design if we dont have option to get the expected result which i posted. Just curious if there is any option to query it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query logic</title><link>https://community.appian.com/thread/136699?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2024 18:39:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dfec0276-779b-4731-8cd0-4cfd6b4fb11a</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Well, to be honest, this looks like a problematic data model design. Is there a specific reason to store a pipe-separated list of values in a single field?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>