<?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 SQL variables in a notebook in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/sql-variables-in-a-notebook/m-p/27421#M19293</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;In an SQL notebook, using this link: &lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/set.html" target="test_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/set.html&lt;/A&gt; I managed to figure out to set values and how to get the value.&lt;/P&gt;
&lt;P&gt;SET my_val=10; //saves the value 10 for key my_val&lt;/P&gt;
&lt;P&gt;SET my_val; //displays the value for the key my_val&lt;/P&gt;
&lt;P&gt;How can I use this value in my SQL query? I tried a few things it's not working:&lt;/P&gt;
&lt;P&gt;select * from mytable where Id=[value of my_val]&lt;/P&gt;
&lt;P&gt;Basically in the example above, I want the select to run for Id=10.&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;
&lt;P&gt;EDIT: if there's a different/better way to accomplish this, I'm all ears &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Nov 2019 19:32:28 GMT</pubDate>
    <dc:creator>MikeK_</dc:creator>
    <dc:date>2019-11-29T19:32:28Z</dc:date>
    <item>
      <title>SQL variables in a notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-variables-in-a-notebook/m-p/27421#M19293</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;In an SQL notebook, using this link: &lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/set.html" target="test_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/set.html&lt;/A&gt; I managed to figure out to set values and how to get the value.&lt;/P&gt;
&lt;P&gt;SET my_val=10; //saves the value 10 for key my_val&lt;/P&gt;
&lt;P&gt;SET my_val; //displays the value for the key my_val&lt;/P&gt;
&lt;P&gt;How can I use this value in my SQL query? I tried a few things it's not working:&lt;/P&gt;
&lt;P&gt;select * from mytable where Id=[value of my_val]&lt;/P&gt;
&lt;P&gt;Basically in the example above, I want the select to run for Id=10.&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;
&lt;P&gt;EDIT: if there's a different/better way to accomplish this, I'm all ears &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 19:32:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-variables-in-a-notebook/m-p/27421#M19293</guid>
      <dc:creator>MikeK_</dc:creator>
      <dc:date>2019-11-29T19:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: SQL variables in a notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-variables-in-a-notebook/m-p/27422#M19294</link>
      <description>&lt;P&gt;Hi @Mike K.., you can do this with widgets and getArgument. &lt;/P&gt;&lt;P&gt;Here's a small example of what that might look like: &lt;A href="https://community.databricks.com/s/feed/0D53f00001HKHZfCAP" target="test_blank"&gt;https://community.databricks.com/s/feed/0D53f00001HKHZfCAP&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 07:38:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-variables-in-a-notebook/m-p/27422#M19294</guid>
      <dc:creator>shyam_9</dc:creator>
      <dc:date>2019-12-02T07:38:37Z</dc:date>
    </item>
  </channel>
</rss>

