nielsv
nielsv

Reputation: 6830

Where query from other table + Doctrine

I'm stuck with creating a where query.
I have table item with item_id, item_title, item_description, item_created, item_approved. I also have a table article with PK item_id (from item table) and article_body. The last table is media with medium_id, item_id (FK), medium_url and medium_type.

Now I would like to select all the data from media where item.item_approved is not NULL and where item.item_id ins't present in the article table. Now I can select all the data from media where item.item_approved is not NULL. But now I need to do another check that he doesn't select the items that are also in article table. My query so far:

$repository = $entityManager->getRepository('VolleyScoutBundle:Media');

$query = $repository->createQueryBuilder('m')
    ->join('m.item', 'i')
    ->where('i.itemApproved is not NULL')
    ->getQuery();

Upvotes: 0

Views: 62

Answers (1)

Victor Bocharsky
Victor Bocharsky

Reputation: 12306

Most likely that you must use 2 queries. With JOINs it can not be done.

Upvotes: 1

Related Questions