Monday, April 26, 2010

Re: SQL with Where not exists

ok but don't you find it fair to post it here? after all you looked
for help and maybe someone like you will find this post and will see:
"I finally found the solution myself."

On Apr 27, 12:07 am, Luck <lucio...@gmail.com> wrote:
> Hi,
>
> After many tries, I finally found the solution myself.
> Thanks
>
> On Apr 26, 4:34 pm, Luck <lucio...@gmail.com> wrote:
>
>
>
> > Hi,
> > I have googled for similar problems and still cannot find a solution
> > on how to build a 'NOT EXISTS' query. I'm newbie to CakePHP.
>
> > I have two simple models: Question and Answer. Question has a hasMany
> > relationship with Answer, as the answers table has a foreign key to
> > questions. Very simple.
>
> > Problem one is, I want to do a find for those queries with no answers,
> > in SQL would be just like this:
>
> > SELECT * FROM questions where not exists (select 1 from anwers where
> > answers.question_id=questions.question_id);
>
> > How do I do this in CakePHP? Is there any way to include other finds
> > in the conditions? I mean not only field matches like the
> > documentation shows.
>
> > The second step is paginate that. How should I alter the current
> > pagination? (currently it paginates all the questions)
> > $this->set('questions',$this->paginate('Question'));
>
> > Thanks
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: