Question: call a function continuously in c# console application. without using infinite loop and recursion because if use those then cpu usage is more.please can any one help me to solve this problem.some one suggest me to use background thread, but it doesn't call the function continuously.

```
Thread th = new Thread(//fun);
th.IsBackground = true;
th.start();

```

Answer: 
You can not use join on update and delete queries. You have to use subqueries.

> 
> Joins are not supported on update and delete queries because it is not
>  supported on all dbms. It won't be implemented in Doctrine 1 or
>  Doctrine 2. You can however get the same affect by using subqueries.
> 
> 
> 

<http://www.doctrine-project.org/jira/browse/DC-646>

If you are using MySQL, using subqueries will not work. You will have then to use 2 queries.

> 
> In MySQL, you cannot modify a table and select from the same table in
>  a subquery
> 
> 
> 

<http://dev.mysql.com/doc/refman/5.0/en/subqueries.html>
Very old question, but do not contain an answer in full query builder.

So yes, the following query is not possible to sync fields of two tables:

```
$this->createQueryBuilder('v')
    ->update()
    ->join(Pegass::class, 'p', Join::WITH, 'v.identifier = p.identifier')
    ->set('v.enabled', 'p.enabled')
    ->where('p.type = :type')
    ->setParameter('type', Pegass::TYPE_VOLUNTEER)
    ->andWhere('v.enabled <> p.enabled');

```

The generated query do not contain the relation because of its lack of support in all dbms as explained above. They also tell you to use subqueries instead.

So that's how I did the equivalent (even if using 2 queries and is less performant...):

```
foreach ([false, true] as $enabled) {
    $qb = $this->createQueryBuilder('v');

    $sub = $this->_em->createQueryBuilder()
        ->select('p.identifier')
        ->from(Pegass::class, 'p')
        ->where('p.type = :type')
        ->andWhere('p.enabled = :enabled');

    $qb
        ->setParameter('type', Pegass::TYPE_VOLUNTEER)
        ->setParameter('enabled', $enabled);

    $qb
        ->update()
        ->set('v.enabled', $enabled)
        ->where($qb->expr()->in('v.identifier', $sub->getDQL()))
        ->getQuery()
        ->execute();
}

```