Reputation: 4820
I know this might seem like a simple question, but its answer has been eluding me for quite some time now. I'm trying to return the number of rows from the databases using the WHERE clause. My query is as follows:
$query = "SELECT COUNT(*)
FROM nfl_current_season_games
WHERE home_team = 'Indianapolis Colts'
AND away_team = 'Chicago Bears'
AND week = '1'";
I'm 100% sure there is such a row. I'm looking right at it in phpmyadmin. No matter if I execute the query with pure SQL in phpmyadmin or in a browser via a php script, it still returns a value of 0. I tried using the var_dump function for the $away_team and $home_team variables with php and they're both just fine. I don't know where to go from here because this seems so odd.
Does anyone have any tips or clues?
Thanks,
Lance
Upvotes: 1
Views: 522
Reputation: 642
Is the data type of 'week' column is string/character? if it is not then just give the value 1 without quote,otherwise (giving in quotes) would have been interpreting it as string/character. Try this query:
$query = "SELECT COUNT(*)
FROM nfl_current_season_games
WHERE home_team = 'Indianapolis Colts'
AND away_team = 'Chicago Bears'
AND week = 1 ";
Upvotes: 0
Reputation: 36156
you probably have blank stapces or a collation issue in one of the column.
I suggest you run the query with one condition at a time and try to find out which one is causing the issue.
When you find out, paste it here to see if we can help
EDIT:
try to do something like (not sure about the mysql syntax, but the idea is to trim to remove blanck spaces and send it to upper):
UPPERCASE(TRIM(away_team)) = 'CHICAGO BEARS'
Upvotes: 3
Reputation: 6566
I finally got it:
The Indianapolis Colts played an away game against the Chicago Bears on week 1.
http://www.colts.com/team/season-schedule.html
Sometimes it isn't a code problem!
Upvotes: 0