Since from is a keyword in MySql ,I'm facing trouble in creating a table having from as one of the column name.I saw one related ques asked ,but it tells how to apply queries on a table that already contains from as one of the attribute .Can anyone help me out.!
Asked
Active
Viewed 677 times
2
-
5Save yourself a world of pain: Don't use a reserved word as table/colum idenitifier – Strawberry Oct 18 '18 at 16:54
-
1Actually its my assignment of sql in which we are already given table name and its attributes..So,no other option left,but to use it.! – Tarishi Jain Oct 18 '18 at 16:57
-
This question has been asked/answered [here](https://stackoverflow.com/questions/15725233/using-reserved-words-in-column-names) – Wrokar Oct 18 '18 at 16:58
-
1Possible duplicate of [Syntax error due to using a reserved word as a table or column name in MySQL](https://stackoverflow.com/questions/23446377/syntax-error-due-to-using-a-reserved-word-as-a-table-or-column-name-in-mysql) – Zack Oct 18 '18 at 17:10
2 Answers
2
If your column name doesn't match the pattern [A-Za-z0-9_]+
or it conflicts with any reserved keywords then you'll need to escape it using backticks:
SELECT `from` FROM `table`
Note that having conflicting names tends to be really annoying because of the special treatment they need, so please, for the sake of anyone that ever has to work with this database, don't do it.

tadman
- 208,517
- 23
- 234
- 262
0
from
is a reserved word in SQL, and I'd strongly advice against using it as a name. If you absolutely have to, you can escape it by using backtiks (`):
ALTER TABLE mytable ADD COLUMN `from` VARCHAR(10)

Mureinik
- 297,002
- 52
- 306
- 350