Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:56:07+00:00 2026-06-02T22:56:07+00:00

Any one have a example how to order before group with leftjoin in zend

  • 0

Any one have a example how to order before group with leftjoin in zend paginator adapter ?

new Zend_Paginator_Adapter_DbSelect($this->db->select()
->from(array( 'a' => $this->prefix.'contest' ), array('id'))
->joinLeft(array( 'b' => $this->prefix.'logo_to_contest'),'a.id=b.contest_id', array('img'))
->group('a.id')
->order('a.end','a.date_start DESC','b.id RAND()')
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:56:11+00:00Added an answer on June 2, 2026 at 10:56 pm

    From mysql manuel

    In general, clauses used must be given in exactly the order shown in
    the syntax description. For example, a HAVING clause must come after
    any GROUP BY clause and before any ORDER BY clause. The exception is
    that the INTO clause can appear either as shown in the syntax
    description or immediately following the select_expr list.

    and in the syntax description group comes before order so it has nothing to do with zend
    it’s mysql that requires that you put group before order.

    However to get around this issue and group after ordering you can select with a subquery with order then group on a new select like :

    $subselect = $db->select()
    ->from(array( 'a' => $this->prefix.'contest' ), array('id'))
    ->joinLeft(array( 'b' => $this->prefix.'logo_to_contest'),'a.id=b.contest_id', array())
    ->order('a.end','a.date_start DESC','b.id RAND()');
    
    $select = $db->select()->from(a(array( 'a' => $this->prefix.'contest' ), array('id'))
    ->joinLeft(array( 'b' => $this->prefix.'logo_to_contest'),'a.id=b.contest_id', array('img'))
    ->where("a.id in ($subselect)")
    ->group('a.id');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

IS this straightforward? Does any one have any good examples? All my google searches
This is a nasty one. I have an external link. <a href=http://www.example.com target=_blank> now
Does anyone have any example on how to put a date time picker inside
For example I have 2 models: Ext.define('Order', { extend : 'Ext.data.Model', fields : [
This question seems to have been asked before, but I feel like my situation
This is not a question where I don't have any ideas, but instead I
Anyone have example Rx code that shows how to execute an action due to
Anyone have an example snippet showing how to scale a Font using AffineTransform? Thanks.
Does anyone have an example of setting up Authlogic with a namespace in Rails?
Does anyone have an example of rendering a remote file in XTK (https://github.com/xtk/X)? Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.