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

[eluser]toopay[/eluser]
Is this query not generates any result too
Code:
SELECT * FROM candidate_details WHERE elect_year = '2011' AND candidate_votes = (SELECT MAX(candidate_votes) FROM candidate_details)
#42

[eluser]Bigil Michael[/eluser]
it generate result
#43

[eluser]toopay[/eluser]
Note that result, then check if it exist within this query result
Code:
SELECT * FROM candidate_details WHERE constituency_id = '1' AND elect_year = '2011'
#44

[eluser]Bigil Michael[/eluser]
yes 3 values
#45

[eluser]Bigil Michael[/eluser]
SELECT * FROM candidate_details WHERE elect_year = '2011' AND candidate_votes = (SELECT MAX(candidate_votes) FROM candidate_details)

this code is working

when i change year from 2011 to 2010

it will print 0 row
#46

[eluser]toopay[/eluser]
Try this...
Code:
SELECT * FROM candidate_details WHERE candidate_votes = (SELECT MAX(candidate_votes) FROM candidate_details WHERE constituency_id = '1' AND elect_year = '2011')
#47

[eluser]Bigil Michael[/eluser]
now it is running thank you so much
#48

[eluser]toopay[/eluser]
Just make sure you post your thread in right section next time.
#49

[eluser]Bigil Michael[/eluser]
i have lot of problems to solve now
#50

[eluser]Bigil Michael[/eluser]
now i want to print the result like this

Quote:2011



Constituency District Winning candidate Name Party Total votes received

Aa k C l 1234
Ab k A m 45465
Ac N B N 123

but these values are inside 3 tables

i will send u the tables
election_year with fields constituency_id year constituency district

constituency_details with fields id constituency_name constituency_id elect_year total_voters total_polled valid_votes invalid_votes

candidate_details with fields id constituency_id candidate_name candidate_party candidate_votes percentage_votes elect_year

my requirement is that when client search result of any year
it will show all result on that purticular year
ie all constituencies and winning candidates of that year

i didn't joined 3 tables till this time

can u help me ??
thanks in advance..




Theme © iAndrew 2016 - Forum software by © MyBB