based on How can I merge these mysql statements I have the following working sql statement:
SELECT *, max(DUP_NUMBER) as dup FROM table1 where CONTACTS=1 GROUP BY FIELD_A ORDER BY date LIMIT 3
I am using the redbean ORM http://redbeanphp.com/finding_beans , which uses 'bean' objects to represent rows. I would like to use a specific method called findAll which requires that the assosciated sql query start with the WHERE keyword
$all = R::findAll('needle',' where $sql ');
It seems unlikely but I figured I would ask , given this constraint is there anyway to rewrite the entire query above into a WHERE SQL clause. something like:
" WHERE max(DUP_NUMBER) as dup where CONTACTS=1 GROUP BY FIELD_A ORDER BY date LIMIT 3 "
THE "SELECT *" and " from table" are taken care of by the R::findAll. If this is impossible I will simply do it another way.
Thanks in advance,
Bill