SQL variables in a notebook

MikeK_
New Contributor II

Hi,

In an SQL notebook, using this link: https://docs.databricks.com/spark/latest/spark-sql/language-manual/set.html I managed to figure out to set values and how to get the value.

SET my_val=10; //saves the value 10 for key my_val

SET my_val; //displays the value for the key my_val

How can I use this value in my SQL query? I tried a few things it's not working:

select * from mytable where Id=[value of my_val]

Basically in the example above, I want the select to run for Id=10.

Thanks in advance.

Mike

EDIT: if there's a different/better way to accomplish this, I'm all ears 🙂