Re: subquery and unionall

2011-09-16 Thread WebbedIT
You sent me a direct email, but I prefer to offer what support I can
in here.

Sorry, I can't help with this as I have never used a MySQL Union.  I
had to search on what a UNION was and cannot come up with a situation
where I would need to use it?!?

If I had two tables with identical fields I would merge the tables to
preserve a normalised database.

Paul

On Sep 16, 2:17 pm, Sivaramakrishnan S  wrote:
> hi,
>
> Anyone knows a good way to make UNION query in CakePHP? I would like
> to avoid using $this->query();.
>
> for this code =>
>
> "Select distinct bm.id,name, add
>                                                    From table1 bm,
>                                                    (Select id bid, count(id) 
> cnt
>                                                    from table2
>                                                    where status = 'N'
>                                                    group by id
>                                                    union all
>                                                    Select id bid, count(id) 
> cnt
>                                                    from table3
>                                                    where status = 'N'
>                                                    group by id
>                                                    order by cnt
>                                                    limit 10) ab Where id = 
> bm.id"

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


subquery and unionall

2011-09-16 Thread Sivaramakrishnan S
hi,

Anyone knows a good way to make UNION query in CakePHP? I would like
to avoid using $this->query();.


for this code =>


"Select distinct bm.id,name, add
   From table1 bm,
   (Select id bid, count(id) cnt
   from table2
   where status = 'N'
   group by id
   union all
   Select id bid, count(id) cnt
   from table3
   where status = 'N'
   group by id
   order by cnt
   limit 10) ab Where id = 
bm.id"

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php