Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i use
MySQL


this is the sql statment i wrote to return result i want the first 30 player it only return first player


SQL
SELECT name  FROM `p_players` WHERE (is_blocked <> '0' AND is_active = '1') order by
total_people_count DESC,  gold_num DESC ,
 attack_points DESC , defense_points DESC , hero_level DESC , week_thief_points DESC , hero_points DESC , villages_count DESC LIMIT 0,30


<img src="http://www11.0zz0.com/2014/06/16/12/100993199.png"/>

then it only return x the result must be more than one result
Posted
Updated 16-Jun-14 3:33am
v3

Since you don't restrict the number of values returned with a "TOP n" CLAUSE ON your SELECT statement, SQL will return all matching rows. You need to look at your data, because if SQL is returning one row, that;s because there is only one row which is matches "is_blocked <> '0' AND is_active = '1'"
 
Share this answer
 
Comments
TheSniper105 16-Jun-14 9:21am    
check the image please http://www11.0zz0.com/2014/06/16/12/100993199.png

is_blocked =1 and is_active is 1 in all rows
Your SQL Statement is correct, but it seems you have leading spaces in your values and it will not match your conditions.
Don't save numeric values as in string type column. All these issues due to that. if you can't change your column types to int or some other numeric type do as below. Use Trim function

SQL
SELECT name  FROM supportContacts
WHERE (trim(is_blocked) <> '0' AND trim(is_active) = '1') .....
 
Share this answer
 
v2
Comments
TheSniper105 16-Jun-14 10:58am    
same result nothing happens
DamithSL 16-Jun-14 11:08am    
can you past the sql you tried? and also what is the column type of is_blocked and is_active?
TheSniper105 17-Jun-14 5:56am    
is_active and is_blocked are tinyint
_________________________________________________________________
sql statment

SELECT name, SUM(total_people_count+gold_num+attack_points+defense_points+hero_level+week_thief_points+hero_points+villages_count) as points
FROM `p_players`
WHERE (is_blocked <> '0' AND is_active = '1')
order by total_people_count, gold_num , attack_points , defense_points , hero_level, week_thief_points, hero_points , villages_count DESC
LIMIT 0,30

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900