Welcome Guest, Not a member yet? Register   Sign In
selecting data from 2 tables
#51

[eluser]Bigil Michael[/eluser]
can u help me
this is the code i used print the result according to any purticular year
Quote:SELECT con.constituency_name, con.elect_year, con.constituency_id, con.total_voters, con.total_polled ,can.candidate_name, can.candidate_votes FROM constituency_details AS con, candidate_details AS can WHERE can.constituency_id = con.constituency_id AND can.elect_year = 2011 AND con.elect_year = 2011 AND candidate_votes = (SELECT MAX(candidate_votes)FROM candidate_details)

but it print the result only once

can u help he??

i think a small change required in my query.....

if possible please help me......
thanks in advance.
#52

[eluser]toopay[/eluser]
This thread may give you a hint.
#53

[eluser]Bigil Michael[/eluser]
problem solved
this is the query
Quote:SELECT constituency_details.constituency_name, constituency_details.total_voters, constituency_details.total_polled ,candidate_details.candidate_name, candidate_details.candidate_party, candidate_details.candidate_votes FROM constituency_details , candidate_details WHERE candidate_details.constituency_id = constituency_details.constituency_id AND candidate_details.elect_year = $elect_year AND constituency_details.elect_year = $elect_year AND candidate_votes = (SELECT MAX(candidate_votes)FROM candidate_details WHERE elect_year=$elect_year AND candidate_details.constituency_id = constituency_details.constituency_id)
#54

[eluser]Bigil Michael[/eluser]
can u help me???
iam in a majour problem,no one responding
i want to find out the second maximum value
Quote:SELECT * FROM candidate_details WHERE candidate_votes=(SELECT max(candidate_votes) FROM candidate_details WHERE candidate_votes< (SELECT max(candidate_votes) FROM candidate_details))

this code is running smoothly

when i added extra condition it is not working
Quote:SELECT * FROM candidate_details WHERE candidate_votes=(SELECT max(candidate_votes) FROM candidate_details WHERE candidate_votes< (SELECT max(candidate_votes) FROM candidate_details)) AND elect_year = '2010'
can u help me?
please....




Theme © iAndrew 2016 - Forum software by © MyBB