<?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 How do I escape single quote within DBXquery SQL like command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-escape-single-quote-within-DBXquery-SQL-like-command/m-p/642314#M222498</link>
    <description>&lt;P&gt;how do I escape single quote within DBXquery SQL like command&lt;BR /&gt;For example:&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;content = '. . . . . .&amp;nbsp; src_port': 20, 'dst_port': 21&amp;nbsp; &amp;nbsp; &amp;nbsp;.....&amp;nbsp; &amp;nbsp;'&amp;nbsp; there is space after colon :&lt;BR /&gt;&lt;/SPAN&gt;| dbxquery connection=visibility query="select&amp;nbsp; content from DB where content like '%port\'\:\s20\,' "&lt;BR /&gt;This query gave me an error.&amp;nbsp; I already tried to escape single quote with single quote, but did gave me 0 result&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2023 15:54:04 GMT</pubDate>
    <dc:creator>LearningGuy</dc:creator>
    <dc:date>2023-05-04T15:54:04Z</dc:date>
    <item>
      <title>How do I escape single quote within DBXquery SQL like command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-escape-single-quote-within-DBXquery-SQL-like-command/m-p/642314#M222498</link>
      <description>&lt;P&gt;how do I escape single quote within DBXquery SQL like command&lt;BR /&gt;For example:&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;content = '. . . . . .&amp;nbsp; src_port': 20, 'dst_port': 21&amp;nbsp; &amp;nbsp; &amp;nbsp;.....&amp;nbsp; &amp;nbsp;'&amp;nbsp; there is space after colon :&lt;BR /&gt;&lt;/SPAN&gt;| dbxquery connection=visibility query="select&amp;nbsp; content from DB where content like '%port\'\:\s20\,' "&lt;BR /&gt;This query gave me an error.&amp;nbsp; I already tried to escape single quote with single quote, but did gave me 0 result&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 15:54:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-escape-single-quote-within-DBXquery-SQL-like-command/m-p/642314#M222498</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2023-05-04T15:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I escape single quote within DBXquery SQL like command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-escape-single-quote-within-DBXquery-SQL-like-command/m-p/642477#M222556</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Escape sequences vary by SQL implementation, but generally, an apostrophe can be included in a character string with a preceding apostrophe, e.g.:&lt;/P&gt;&lt;PRE&gt;SELECT 'FOO''BAR'&lt;/PRE&gt;&lt;P&gt;returns FOO'BAR, where the double apostrophe is replaced with a single apostrophe.&lt;/P&gt;&lt;P&gt;In your example:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;| dbxquery connection=visibility query="select content from DB where content like '%port'': 20,' "&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;will return the content column from all DB table rows where content ends with port':[space]20,'[space].&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;To find all rows containing a src_port or dest_port string (or any other _port': string), you might try:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;| dbxquery connection=visibility query="select content from DB where content like '''%\_port'':%' escape '\'"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;In LIKE predicate patterns, % and _ are wildcards. I've introduced the ESCAPE clause to explicitly define an escape character.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LIKE predicate patterns are not regular expressions, so you may match more than you intended.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2023 18:11:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-escape-single-quote-within-DBXquery-SQL-like-command/m-p/642477#M222556</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2023-05-06T18:11:35Z</dc:date>
    </item>
  </channel>
</rss>

