Friday, May 7, 2010

how to select from subquery result

Hello
for the life of me I coudn't find an example of how to do the
following:
SELECT * FROM (SELECT * FROM mytable WHERE some_id=1 ORDER BY DATE
DESC) t1 GROUP BY block_id

The query needs to select the latest entries for each block_id in the
table (like selecting the latest comment for each blog post would be
an equivalent scenario).

I would need to implement this with pagination, but I would just like
to get it to work with find() for now.

Is a custom query maybe the only way to do this?

Thanks!

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate