allydm Posted December 13, 2006 Share Posted December 13, 2006 Hi there.I have a select query pulling information from my table correctly on most pages apart from a few, and my problem has really confused me.Basically, the pages contain a sports league tables and the info is pulled out on every page load.To best explain the problem, i've taken a screen shot of it...[img]http://www.allydm.co.uk/images/php-problem.gif[/img]Now, the problem is that it is falsly executing, as i specify that the home_team_score should be greater than the away team score...HOWEVER as you can see in the result that it gets, the home_team_score is 3 whereas the away_team_score is infact 12.Any ideas why this is happening? Link to comment https://forums.phpfreaks.com/topic/30490-mysql-select-statement-problem/ Share on other sites More sharing options...
obsidian Posted December 13, 2006 Share Posted December 13, 2006 What are the data types of your home_team_score and away_team_score fields? If they are some type of character field (CHAR, VARCHAR or TEXT), it is a legitimate result since it's sorting them alphabetically and 3 comes after 1 when sorted by alpha.Your data types on those fields should be INT most likely. One possible solution, if your data types are indeed characters would be to try and see if MySQL will let you type cast the columns for your comparison:[code]SELECT * FROM fixtures WHERE SIGNED INTEGER home_team_score > SIGNED INTEGER away_team_score;[/code]Obviously, you'd want to include your other WHERE clauses in there, too, but this should give you an idea of how to handle your scores if they're not in a numeric data format.Hope this helps! Link to comment https://forums.phpfreaks.com/topic/30490-mysql-select-statement-problem/#findComment-140391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.