Concatenate two fieds in an EntityQuery condition I'm trying to query some nodes by a given string checking if the string is either in the node title OR if the string is an exact match of concatenating the value of two strings.

I know this should be possible in normal mysql but not sure it can be translated in an entity query. Has anyone stumbled upon this problem before?

Is there some sort of 'free text' condition which is not tied up to fields.

At the moment the below code complains about the fact that CONCAT_WS(...) is not a field which is true.

Maybe there is a simpler solution to this but I'm just not seeing it.


$query = \Drupal::entityQuery('node')
        ->condition('status', 1)
        ->condition('type', 'CONTENT_TYPE');

$group = $query->orConditionGroup()
        ->condition('title', $string , 'CONTAINS')
        ->condition("CONCAT_WS('',FIELD_1,FIELD_2)", $string);

$query->condition($group);
$nids = $query->execute();
I don't think it's possible this way.
I would rather split the $string in two parts, and check the two fields with each part.

$query-&gt;condition("FIELD_1)", $string_1);
$query-&gt;condition("FIELD_2)", $string_2);


You have many ways to separate the string in two.
Is this helping you ?