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

[eluser]Bigil Michael[/eluser]
when i change year and constituence
result print like this


string(167) "SELECT * FROM (`candidate_details`) WHERE `constituency_id` = '1' AND `elect_year` = '2011' AND `candidate_votes` = (SELECT MAX(candidate_votes)FROM candidate_details)" array(0) { }
#32

[eluser]Bigil Michael[/eluser]
candidate votes integer
#33

[eluser]toopay[/eluser]
Unbelievable. Run this query directly in mysql daemon or phpmyadmin
Code:
SELECT * FROM candidate_details WHERE constituency_id = '1' AND elect_year = '2011' AND candidate_votes = (SELECT MAX(candidate_votes) FROM candidate_details
#34

[eluser]Bigil Michael[/eluser]
upto this it is running
SELECT * FROM candidate_details WHERE constituency_id = '1' AND elect_year = '2011'


when i use fullcode

SELECT * FROM candidate_details WHERE constituency_id = '1' AND elect_year = '2011' AND candidate_votes = (SELECT MAX(candidate_votes) FROM candidate_details

it shows error like this

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
#35

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

[eluser]Bigil Michael[/eluser]
now error gone

but it prints 0 rows
#37

[eluser]toopay[/eluser]
Pfff. Its sounds unbelievable. Ok, try it step by step.
Code:
SELECT * FROM candidate_details WHERE candidate_votes = (SELECT MAX(candidate_votes) FROM candidate_details)
#38

[eluser]Bigil Michael[/eluser]
it prints result
but when i use this
SELECT * FROM candidate_details WHERE constituency_id = '1' AND elect_year = '2011' AND candidate_votes = (SELECT MAX(candidate_votes) FROM candidate_details)
prints 0 result
#39

[eluser]toopay[/eluser]
Is there ANY RECORD which match with above 'where' rules?
#40

[eluser]Bigil Michael[/eluser]
yes 3 records are there
i will send the table
Quote:id constituency_id candidate_name candidate_votes elect_year
1 2 Selvaraj 3647 2011
2 4 babu 4678 2010
4 1 George 83647 2011
5 1 Nagappan 878787 2011
6 1 Suresh 67565 2011
7 2 Ravi 879 2011
8 2 sajith 7878 2011
10 1 ssssssss 21474 2010




Theme © iAndrew 2016 - Forum software by © MyBB