Skip to content

Spark SQL passing a variable

I have following Spark sql and I want to pass variable to it. How to do that? I tried following way. Answer You are almost there just missed s 🙂

Select certain column only if condition met

I want to have a select that will not have fixed number of columns. Column OptionalColumn should be selected only if variable @check = 1 This is what I had (syntax is bad but maybe it explains my problem) It is crucial to have it only if @Check = 1 and not having it if @Check = 0. Is it

MySQL: How to convert seconds to mm:ss format?

I want to convert seconds to minute : seconds format in sql select statement. At the moment I am using: It works perfectly but it gives me this format of time: hh:mm:ss but I need mm:ss Is it possible to convert seconds into mm:ss format using sql query? Answer If the value is less than an hour, then just do:

Update and insert to one table from another

I have two tables: table1: (ID, Code, Name) table2: (ID, Code, Name) with same columns I want to to insert data from table1 to table2 or update columns if that exists in table2 (table1.ID = table2.ID) What is the simple way to do this? WITH OUT MERGE Answer There are some issues with Merge statement,so it sho…

Checking if a value exists in sqlite db with Go

I’m writing code to manage users in a sqlite database with Go. I’m trying to check if a username is taken, but my code is ugly. My table looks like: And I check if a username is taken with: Is there a better query I could use that would tell me if the username value exists in the table in