Some things I’ve learnt recently.
Simple boolean function to check if a column exists
SELECT EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name = tabname AND column_name = col1)
Identify duplicate values in columns
SELECT key FROM tabname GROUP BY key HAVING (COUNT(key) > 1)
col1 is an integer but I wanted it formatted as text in my python script
SELECT CAST(col1 AS TEXT) FROM tabname
Advertisement