<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136944#M7887</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If commas are prepended and appended to the field in question, either to the data itself or a DBMS-specific concatenation function, a single LIKE statement of &lt;SPAN style="font-family: courier new,courier;"&gt;'%,1,%'&lt;/SPAN&gt; will work.&amp;nbsp; Using SQL Server and concatenation function:&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14663101816218180 jive_text_macro" data-renderedposition="60.959999084472656_8_982_16" jivemacro_uid="_14663101816218180"&gt;&lt;P&gt;WHERE CONCAT(',', intx_field, ',') LIKE ('%,1,%')&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14663104560883796" data-renderedposition="102.95999908447265_8_982_16" jivemacro_uid="_14663104560883796"&gt;&lt;P&gt;WHERE ',' + intx_field + ',' LIKE ('%,1,%')&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 19 Jun 2016 04:23:10 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2016-06-19T04:23:10Z</dc:date>
    <item>
      <title>How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136939#M7882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I’ve used the &lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/analysis/spatial-join.htm"&gt;Spatial Join geoprocessing tool&lt;/A&gt; using the JOIN_ONE_TO_ONE option to join a line feature class (target) and polygon feature class (join). I’ve also used the &lt;A href="http://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/field-map.htm"&gt;merge rule of join &lt;/A&gt;on an ID field with a comma delimiter. So in my resulting feature class has one feature for each of the inputs but it has a field with a comma delimited list of the IDs for the polygons that each line intersected with (like what is described in &lt;A href="https://esriaustraliatechblog.wordpress.com/2015/06/22/spatial-joins-hidden-trick-or-how-to-transfer-attribute-values-in-a-one-to-many-relationship/"&gt;this blog&lt;/A&gt;). So if line A intersected with polygon 1 and 2 it would have a value of ‘1,2’. Now I want to build a query that returns all the lines that intersected polygon 1. You might think that a SQL statement that uses the LIKE operator would work, but then any polygon with 1 in the ID would also be returned (Like ID = 10 or 100). What I really need is something like the IN operator but with the field values providing the list. But I can’t get that to work. Does anyone have an idea on how to build this query? Ideally I would make this query from the operations dashboard but any examples would do. One more snag. If you are thinking of using a bitmask, I have more than 64 polygon IDs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:14:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136939#M7882</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2016-06-15T22:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136940#M7883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;don't know about the query but here is an example that might work in some situations&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = '10,3,1,2'&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; str(2) in a.split(',')&lt;/P&gt;&lt;P&gt;True&lt;/P&gt;&lt;P&gt;You can get elaborate and convert the split values to numbers if you want&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:56:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136940#M7883</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-15T22:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136941#M7884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With SQL, I think the "proper" way to do this would be with regular expressions (regex). Not sure if you need SQL Server or Oracle syntax but you can go on the regex adventure yourself. An uglier/messier way to do this would be to just have three &lt;SPAN style="font-family: 'courier new', courier;"&gt;LIKE&lt;/SPAN&gt; statements; one for each possible scenario the search string could exist.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;where intx_field like '1,%'&amp;nbsp; -- Beginning
&amp;nbsp;&amp;nbsp;&amp;nbsp; or &lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;intx_field &lt;/SPAN&gt;like '%,1,%'&amp;nbsp; -- Middle
&amp;nbsp;&amp;nbsp;&amp;nbsp; or &lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;intx_field &lt;/SPAN&gt;like '%,1'&amp;nbsp; -- End
&amp;nbsp;&amp;nbsp;&amp;nbsp; or intx_field = '1'&amp;nbsp; -- Single&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Editied to include where clause for single value; thanks &lt;A href="https://community.esri.com/migrated-users/4811" target="_blank"&gt;Richard Fairhurst&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:36:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136941#M7884</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T07:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136942#M7885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like “%” that solution. Get it? Ah SQL jokes are the best.&lt;/P&gt;&lt;P&gt;You would just need to add a line for each significant digit which in my case is 3. Good idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking regex but wasn’t too excited about that. Thanks for the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 23:50:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136942#M7885</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2016-06-16T23:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136943#M7886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You forgot to include:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or intx_field = '1'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2016 10:04:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136943#M7886</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-06-17T10:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136944#M7887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If commas are prepended and appended to the field in question, either to the data itself or a DBMS-specific concatenation function, a single LIKE statement of &lt;SPAN style="font-family: courier new,courier;"&gt;'%,1,%'&lt;/SPAN&gt; will work.&amp;nbsp; Using SQL Server and concatenation function:&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14663101816218180 jive_text_macro" data-renderedposition="60.959999084472656_8_982_16" jivemacro_uid="_14663101816218180"&gt;&lt;P&gt;WHERE CONCAT(',', intx_field, ',') LIKE ('%,1,%')&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14663104560883796" data-renderedposition="102.95999908447265_8_982_16" jivemacro_uid="_14663104560883796"&gt;&lt;P&gt;WHERE ',' + intx_field + ',' LIKE ('%,1,%')&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jun 2016 04:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136944#M7887</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-06-19T04:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136945#M7888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As usual, &lt;A href="https://community.esri.com/migrated-users/3420"&gt;Joshua Bixby&lt;/A&gt;​ has a more elegant solution. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/laugh.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 18:48:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136945#M7888</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2016-06-20T18:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a query to return the unique occurrences of an ID from a field containing a comma delimited string</title>
      <link>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136946#M7889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.&amp;nbsp; Overall, the OP's approach is very non-relational, so I don't know how elegant any specific syntax can be.&amp;nbsp; In a relational context, there would be a second table that lists each feature along with each intersecting feature, and a simple SELECT, and possibly a JOIN, would be used to identify the features.&amp;nbsp; Unfortunately, being relational in ArcGIS isn't always straightforward, so practicality wins out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 20:50:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-to-build-a-query-to-return-the-unique/m-p/136946#M7889</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-06-20T20:50:37Z</dc:date>
    </item>
  </channel>
</rss>

