title: Get values of all fields for an list of ids  without specifying their id in mysql query?
body: <p>i have an sql query from which i am getting sum of weightage for all the answers linked to an agent. its working for me when i specify an agent id for example 1 .</p>
  
  <p>but i would like to know</p>
  
  <ul>
  <li><p>is it possible without specify an agent id i get all the answers linked to all the agents that i have in db i am not getting idea how to do that am usind zend ?</p></li>
  <li><p>can an sql query be looped if i have an array of agents and make it return all the  weigtage of all the agent to return the agents weigtage for a specific question in an array form.</p></li>
  </ul>
  
  <p><b>table structure for tables </b></p>
  
  <p><b>table structure for table agents </b></p>
  
  <p>agent_id // al agent ids 
  1
  2
  3</p>
  
  <p><b>table structure for table answer </b></p>
  
  <p>answer_id // all answer ids     weigtage // to be addded has sum for each agent indivually
   11                              1
   12                              0
   13                             -1 </p>
  
  <p><b>table structure for table customer survey </b></p>
  
  <p>// customer id          // fault id          // survey id 
        1                     1                       4
        2                     3                       5</p>
  
  <p><b>table structure for table faults </b></p>
  
  <p>fault_id     agent_id</p>
  
  <p>// 3          3</p>
  
  <p>//4           5                   //   all this is random data </p>
  
  <p><b>table structure for table response </b></p>
  
  <p>// response id       survey id   customer_id     answer id
  response_id           sq_id         cs_id         answer_id   </p>
  
  <p><b>table structure for table survey_question </b></p>
  
  <p>survey_id     question_id</p>
  
  <p><b>each answer is associated with an fault . and a fault with agent . customer takes a survey . fault with customer response . custome response cs_id to response . question is asscoacited with a particular survey. and ya its confusing a bit took me two days </b></p>
  
  <ul>
  <li>i have 20 random agent ids and i need to kinda loop through them in mysql and get the result for each agent id . at present at a time i am getting for one agent.</li>
  </ul>
  
  <hr>
  
  <pre><code>SELECT SUM( weightage )
  FROM answer a
  WHERE a.answer_id
    IN (
      SELECT r.answer_id
      FROM response r, survey_question sq
      WHERE r.sq_id = sq.sq_id
        AND sq.survey_id =4
        AND sq.question_id =28
        AND r.cs_id
          IN (
            SELECT cs.cs_id
            FROM customer_survey cs, faults f
            WHERE cs.fault_id = f.fault_id
              AND agent_id =1
          )
    )`
  </code></pre>
  
  <p>the output of this query for an single agent is </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
      (
         [SUM( weightage )] =&gt; 2
      )
  )
  </code></pre>
  
  <p>i would like the output to be like based on agent ids like</p>
  
  <pre><code>Array
  (
  //  agent id 1
       [1] =&gt; Array 
       (
           [SUM( weightage )] =&gt; 2
       )
  // agent id 2
      [2] =&gt; Array 
      (
          [SUM( weightage )] =&gt; -1
      )
  // agent id 3
      [3] =&gt; Array 
      (
          [SUM( weightage )] =&gt; 5
      )
  // agent id 4
      [4] =&gt; Array 
      (
          [SUM( weightage )] =&gt; 4
      )
  // agent id 5
      [5] =&gt; Array 
      (
          [SUM( weightage )] =&gt; 11
      )
  )
  </code></pre>