<?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: Multiple SQL's in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/multiple-sql-s/m-p/1062409#M61249</link>
    <description>&lt;P&gt;You can use the &lt;FONT face="courier new,courier"&gt;AND&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operator to combine the SQL statements depending on what you're trying to achieve.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sql_expression = "({}) and ({})".format(SQL1, SQL2)&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sql_expression = "({}) or ({})".format(SQL1, SQL2)&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 27 May 2021 16:36:16 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-05-27T16:36:16Z</dc:date>
    <item>
      <title>Multiple SQL's</title>
      <link>https://community.esri.com/t5/python-questions/multiple-sql-s/m-p/1062406#M61248</link>
      <description>&lt;P&gt;I currently have two sql's queries in a script, is there a way to combine SQL1 &amp;amp; SQL2 so I am not doing two separate queries?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;table1 = r"C:\Temp\Table"

from_date = DT.date.today() - DT.timedelta(days=730)
SQL1 = "AppSubmitted &amp;gt;= DATE '{}'".format(from_date.strftime('%Y-%m-%d')) #'%Y-%m-%d %H:%M:%S'

SQL2 = "PNum LIKE 'RZ%' OR PNum LIKE 'OR%' OR PNum LIKE 'CR%'"
arcpy.MakeTableView_management(table1, 'tableview', SQL) #Include SQL2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 16:28:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-sql-s/m-p/1062406#M61248</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-05-27T16:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple SQL's</title>
      <link>https://community.esri.com/t5/python-questions/multiple-sql-s/m-p/1062409#M61249</link>
      <description>&lt;P&gt;You can use the &lt;FONT face="courier new,courier"&gt;AND&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operator to combine the SQL statements depending on what you're trying to achieve.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sql_expression = "({}) and ({})".format(SQL1, SQL2)&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sql_expression = "({}) or ({})".format(SQL1, SQL2)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 May 2021 16:36:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-sql-s/m-p/1062409#M61249</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-05-27T16:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple SQL's</title>
      <link>https://community.esri.com/t5/python-questions/multiple-sql-s/m-p/1062426#M61250</link>
      <description>&lt;P&gt;Sweet, thank you.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SQL1 = "AppSubmitted &amp;gt;= DATE '{}'".format(from_date.strftime('%Y-%m-%d')) #'%Y-%m-%d %H:%M:%S'

SQL2 = "PNum LIKE 'RZ%' OR PNum LIKE 'OR%' OR PNum LIKE 'CR%'"
sql_expression = "({}) and ({})".format(SQL1, SQL2)
arcpy.TableToTable_conversion(table1, workspace,'tableTEST', sql_expression)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 May 2021 17:02:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-sql-s/m-p/1062426#M61250</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-05-27T17:02:32Z</dc:date>
    </item>
  </channel>
</rss>

