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 8737457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:31:39+00:00 2026-06-13T10:31:39+00:00

I did following function and it’s working fine. public function getLatestCurrencyRates(){ $sql = new

  • 0

I did following function and it’s working fine.

public function getLatestCurrencyRates(){
        $sql = new Sql($this->adapter);

        $subselect2 = $sql->select();
        $subselect2->from(array('r1' =>'currency_rates'))
                    ->columns(array('max_c_rate_id' => new Expression('MAX(c_rate_id)')))
                    ->group("currency_id");


        $statement = $sql->prepareStatementForSqlObject($subselect2);
        $result = $statement->execute();
        $rows = array_values(iterator_to_array($result));
        return $rows;
    }

I’m going to join above select statement with same table. Can anyone suggest how to do that? My current implementation as follows. Actually it’s not completed. Because lack of knowledge to implement it.

public function getLatestCurrencyRates(){
        $sql = new Sql($this->adapter);

        $subselect2 = $sql->select();
        $subselect2->from(array('r1' =>'currency_rates'))
                    ->columns(array('max_c_rate_id' => new Expression('MAX(c_rate_id)')))
                    ->group("currency_id");


        $subselect3 = $sql->select();
        $subselect3->from("currency_rates")
                    ->join(array('r2'=>$subselect2), 'r2.max_c_rate_id = currency_rates.c_rate_id', array('c_rate_id', 'currency_id', 'buy_rate', 'sell_rate'));



        $statement = $sql->prepareStatementForSqlObject($subselect3);
        $result = $statement->execute();
        $rows = array_values(iterator_to_array($result));
        return $rows;
    }

SQL query that I’m going to implement here as follows.

 select r1.c_rate_id, r2.currency_id, r2.buy_rate, r2.sell_rate 
 from 
 (select max(c_rate_id)as c_rate_id from currency_rates group by currency_id) as r1
 inner join 
 currency_rates as r2
 on 
 r1.c_rate_id = r2.c_rate_id;

Can anyone give good feedback, will be helpful.

Thanks.

  • 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-13T10:31:40+00:00Added an answer on June 13, 2026 at 10:31 am

    ZF2’s Zend\Db\Sql\Select – at the moment i write this – lacks the support of sub-queries in $select->join(). You can only use them in $select->columns()& $select->where() (with Expressions).

    Edit:

    Only $select->join() lacks the support of sub-queries, $select->from() accepts it. It means the whole sub-query is quoted as an identifier, for now – probably it’ll be fixed in some 2.0.* versions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;
I have a table 'X' and did the following CREATE PARTITION FUNCTION PF1(INT) AS
I am working with a COM plugin interface that has the following function definition:
I have the following function: public class InfrStadium { private InfrStadium(int iTeamId) { _teamId
I have a little problem with creating a new function from a string. The
hey guys, i did the following function in order to have the same height
I did the following steps to use the CDialog in win 32 application: Changed
I did the following but it not work for always.It works if i launch
Im a clojure beginner.I did the following steps as given on http://www.unexpected-vortices.com/clojure/brief-beginners-guide/development-env.html to setup
hay all, I just did the following: a = input(give a word: ) b

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.