How can I validate with IF Block when MySQL Node returns nothing?

When selecting the data from the MySQL database, If there is no data returned how can I change the response as a JSON message instead of “No text data found”

This will be helpful for using IF Node next to it.

I tried enabling this option. But it is just an empty array.

Hi @mcnaveen, you could check for a field that should have been returned in your IF node. E.g. a simple check could be whether the username field is empty using an expression of {{$json["username"]}} in your IF node.

If a user has been returned, the item would go to the false output (because the username field is not empty):

If there is no user, the empty item would go the true output:

You could then connect a Set node to the true output of your IF node to convert this empty JSON into a JSON with the fields you’d like to see.


Oh wow.

Never checked Is Empty under IF Node.

This is nice, Thanks for your response :slight_smile:


Awesome, glad to hear this helps and thanks a lot for confirming :slight_smile:


There is an issue with this approach.

This is my workflow. If the data is returned from the MySQL node. It’s working properly.

But when there is no data. If Node isn’t processing anything.

Here is my workflow

If MySQL node returns No text data found as JSON response. It’ll be a lot easier.

I tried adding Else block after this to turn into JSON response. But I might be doing it wrong.

In your example the “Always Output Data” option appears to be disabled (which was previously enabled as per your screenshot further up):


That’s be why the workflow doesn’t continue here.

1 Like

:100: You’re right.

Thanks a lot.

1 Like