Complicated Not Query

i have 3 tables

"worker","activity" and linking table "workerToActivity"

activity has ‘time’ and ‘activity_id’ Columns

worker has ‘worker_id’ Column

workerToActivity has ‘worker_id’ and 'activity_id’Columns

in my query i want to get all workers that are not register to activity in certain time,

i dont know how to do that

can u help me?

In my cases in the past I used something like that

But when the queries became more comblex I use this one

Yii::app()->db->createCommand('a comblex query')->queryAll()

So you have to check both of two options


FROM worker a

LEFT JOIN workerToActivity b ON b.worker_id=a.worker_id

LEFT JOIN activity c ON c.activity_id=b.activity_id

WHERE b.activity_id IS NULL --no activity assigned

      OR NOT (c.time BETWEEN .. AND ..)

conapaz & Joblo

u both help me alot, thnks.