Reputation: 1073
I'm building a simple app which lists teams and matches. The Team and Match databases were built with the following scripts (I'm using PhpMyadmin):
CREATE TABLE IF NOT EXISTS `Team` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(120) NOT NULL,
`screen_name` varchar(100) NOT NULL,
`sport_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
CREATE TABLE IF NOT EXISTS `Match` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sport_id` int(11) NOT NULL,
`team_one_id` int(11) NOT NULL,
`team_two_id` int(11) NOT NULL,
`venue` varchar(80) NOT NULL,
`kick_off` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
If i do:
SELECT * FROM Team
The script runs and I get an empty result. But, incredibly, if I do
SELECT * FROM Match
I get the following error:
Instead, I have to do:
SELECT * FROM `Match`
And it works. I have other tables in the database but this is the only behaving like this. Any ideas why?
Upvotes: 2
Views: 199
Reputation: 25753
You need encapsulate it in quotes because Match
is a keyword.
See key word list
Upvotes: 1
Reputation: 5349
match
is a reserved word in SQL
Read more here: https://drupal.org/node/141051
Upvotes: 2
Reputation: 1600
Match is a Function in MySQL therefore you must put the quotes around it.
Upvotes: 2