How to run INSERT SQL query depending upon the result of SELECT query?

Hello Everyone,
Is there a possibility to write more than one query in a function node and execute it on single instance of mysql node?. First, i would like to run a select query and then run an insert query only if the result from the first query is not null.

It seems like i need to write individual queries in separate function nodes and also create separate mysql nodes for each function node. Please correct me if my approach is wrong.

I am eagerly looking for a better approach. Any help would be appreciated.

Thanks

Are you trying to do an insert but only if the row does not already exist? If so then Google for
Mysql insert if not exists
And you will find a number of solutions.

Hello Colin,

Thank you very much for your suggestion.
Actually i want to retrieve a column data from a table through SELECT query and then insert this column data as a value into another table through INSERT query. But i do not want to insert to another table if the column data from first table is empty.

Regards,

Hi @Nirajan ,

I'm not sure if this will help or not, but if it were a SQL Server database I'd write something like:

INSERT INTO DestinationTable (TheOnlyColumn)
    SELECT TheOnlyColumn
    FROM SourceTable
    WHERE TheOnlyColumn IS NOT NULL

With this approach, no insert will take place unless the column from the source table is not null.

But, perhaps I haven't understood your requirements fully?

Hallo,

Thanks a lot for your help and for a possible solution.
I will give it a try. I am hoping this will work out.

Best Regards,

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.