TomRenish
New Contributor III

CJS had the best answer by virtue of it being code-based rather than widget-based.  In a notebook where the value of the variable must continually be reset, widgets are suboptimal.  That said, the easiest way is to wrap the code in python:

%py

var1 = some_value ##string, int, whatever

var2 = some_other_value 

qry = f"select * from {var1} where some_field = {var2}" ##use python's format feature to place variables cleanly

display(spark.sql(qry))