1

I want to find tables in my databricks database that meet more than one condition. Mysql allows 'where' clauses to include multiple conditions like this post explains.

To use multiple conditions in databricks, I can use the following syntax, but this is an or clause:

show tables from {database} like "*2008*|*animal*"

I want to find all tables that have** both 2008 and animal** in the name. Thank you in advance for your help.

1 Answers1

0

You could create a spark dataframe, then select from it. Here I converted the DF to a temp view and then wrote plain SQL against the view.

Cmd-1: 
%python

df = spark.sql("show tables in {}".format("your_db_name"))
df.createOrReplaceTempView("df_tempview")

--

Cmd-2: 
%sql

select *
from df_tempview
where tableName like ('%2008%') and tableName like ('%animal%')
Isolated
  • 5,169
  • 1
  • 6
  • 18