Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

How to use NOT EXISTS condition in Drupal 8 & 9


$query = db_select('users');

$query->addField('users', 'uid');

$query_exists = db_select('users_roles');

$result = $query->execute();
foreach ($result as $record) {


By convention, use the following rather using the condition() method:


While a condition such as $query->condition($field, NULL, 'IS NOT NULL'); should work, the above convention is recommended.

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts


Page Facebook