Reputation: 45
What does the `
symbol actually mean in MySQL?
This works:
INSERT INTO person(`name`, `roll_no`, `gender`) VALUES('person1', 1, 'male');
Whereas this throws a syntax error:
INSERT INTO person(name, roll_no, gender) VALUES('person1', 1, 'male');
Upvotes: 1
Views: 2482
Reputation: 20758
The `
just tells MySQL to expect a column name, since name
is a reserved keyword in SQL.
SELECT `name`
in MySQL is the equivalent of SELECT [name]
in T-SQL.
Bonus:
I highly recommend using MySQL Workbench instead of the usual phpMyAdmin. One of the great advantages of using a proper management studio is that this would've been quite obvious:
Notice that name
is highlighted differently, showing that it is a reserved keyword, and needs to be escaped as `name`
.
Upvotes: 8