SELECT .... WHERE NOT IN (subquery)

174 views
Skip to first unread message

Zdenek Hruska

unread,
May 14, 2013, 8:41:27 AM5/14/13
to not...@googlegroups.com
Hi,

i have two tables:
log(id, ....)
log_error(id, log_id, ....)

How do i do this with notorm? Real queries are a bit more complex, but this ilustrate the main problem that i have

SELECT * FROM log L WHERE l.id NOT IN (SELECT log_id FROM log_error)

I can't run subquery separately and use its result in ->where() method because the result is too big

Altering schema is not an option.

thx for help

Jakub Vrana

unread,
Jun 26, 2013, 1:12:06 PM6/26/13
to not...@googlegroups.com
Hi,

Outside MySQL, you should be able to use something like:

$notORM->log("id NOT", $notORM->log_error()->select("log_id"));

In MySQL, you can try something like:

$notORM->log()->where("log_error.log_id", null)

NotORM materializes subselects in MySQL as they are very slow otherwise.
But I can add an option to disable this. Please let me know.

Jakub
> --
> You received this message because you are subscribed to the Google
> Groups "NotORM" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to notorm+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Zdenek Hruska

unread,
Jun 26, 2013, 3:12:48 PM6/26/13
to not...@googlegroups.com
Hi,

thx for reply

i tried this just yesterday and it worked, so i went with it...

->where('id NOT IN (SELECT .....)');

i was just about to post it here today :)

Zdenek
Reply all
Reply to author
Forward
0 new messages