0

I've got the below code

$query = \Drupal::database()
  ->select("excel", "e")->fields("e");
$group = $query->orConditionGroup()
  ->condition("grupindex", 1)
  ->condition("grupkodu", NULL);
$query->condition($group);
$excel_products = $query->execute()->fetchAll();

When I run SELECT * FROM excel WHERE grupkodu = 1 OR grupkodu IS NULL, I get 1594 records, however the above code gives only 638 records, which means only grupkodu condition is taken into account. What is the proper way to apply OR?

0

After a bit of dabbling, I got the answer. ->condition("grupkodu", NULL); is not sufficient, it needs to be ->condition("grupkodu", NULL, "IS NULL");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.