Announcement

Collapse
No announcement yet.

Select a NULL-Value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select a NULL-Value

    Hi,

    when I select some entities from the Database, I will get all entities where have a null value in a column.

    Example:

    $collection = $this->entityManager
    ->getRDBRepository('TargetList')
    ->where([
    'campaignsId' => 'NULL'
    ])
    ->find();

    This does not work. What is the correct statement?

    Best regards

    Stefan

  • #2
    Hi Stefan,

    This definitely should work:

    Code:
    ->where(['accountId' => null])
    Note that you might have the excessive "s" in "campaignsId".

    Comment


    • #3
      As Campaign is related with Target List through a many-to-many relationship type, checking for null won't work. You can leftJoin 'campaigns' link with distinct applied. But I'd recommend using a sub-query in a where clause.

      Comment


      • #4
        Thank you

        Comment

        Working...
        X