Welcome Guest, Not a member yet? Register   Sign In
select maximum problem
#1

[eluser]Bigil Michael[/eluser]
can any one help me

my table
Quote: id constituency_id candidate_name candidate_votes elect_year

1 2 Selvaraj 123456876 2011
2 4 kk 4678 2010
4 1 George 75 2011
5 1 Nagappan 15 2011
6 1 Suresh 5 2011
7 2 Ravi 20 2011
8 2 sajith 5 2011
10 1 sssssss 11111 2010

I want to print candidate name who have maximum candidate_votes.

my model
Quote:function select_winner($consti,$elect_year)
{
$query = $this->db->where('constituency_id', $consti)
->where('elect_year', $elect_year)
->where('candidate_votes = (SELECT MAX(candidate_votes)FROM candidate_details)')
->get('candidate_details');
return $query->row_array();
}

controller
Quote:$this->data['winner'] = $this->Election_result_model->select_winner($consti,$elect_year);

view
Quote:Winning Candidate: Mr. <?php echo $winner['candidate_name'] ?>

can anyone help me?????
urgent......
thanks in advance..
#2

[eluser]toopay[/eluser]
@Bigil MM

1. This forum section (truly) is not appropriate for your problems, because it's not corresponding with any Library, Helper or Ignited Code stuff! Post your thread elsewhere.
2. If you already opening similar or even SAME THREAD, post another new thread is not a good way to get some respond.
3. Over reacting in your post, will not help you to get some nice respond.




Theme © iAndrew 2016 - Forum software by © MyBB