
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Can we use reserved word ‘index’ as MySQL column name?
Yes, but you need to add a backtick symbol to the reserved word (index) to avoid error while using it as a column name.
Let us first create a table −
mysql> create table DemoTable ( `index` int ); Query OK, 0 rows affected (0.48 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1000); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(1020); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(967); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(567); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(1010); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | index | +-------+ | 1000 | | 1020 | | 967 | | 567 | | 1010 | +-------+ 5 rows in set (0.00 sec)
Now let us display some records with our column name `index`. Here, we are displaying 3 records −
mysql> select *from DemoTable order by `index` DESC LIMIT 3;
This will produce the following output −
+-------+ | index | +-------+ | 1020 | | 1010 | | 1000 | +-------+ 3 rows in set (0.00 sec)
- Related Articles
- How can we use the MySQL reserved words as an identifier?
- Can we use MySQL keyword as alias name for a column?
- Is name a reserved word in MySQL?
- Can we use “rank” as column name with MySQL8?
- Will “create table table” work in MySQL since we cannot use reserved words as table name?
- How to resolve the error that occurs while using a reserved word as a table or column name in MySQL?
- Can we use “When” as column name in CREATE TABLE statement?
- Why can't we use column name “desc” in MySQL?
- Can we use “year” as a column came in a MySQL Table?
- Can we use the word user for a MySQL table?
- How can we use MySQL function STR_TO_DATE(Column, ‘%input_format’)?
- Can we use backticks with column value in MySQL?
- Can we use semicolon as a MySQL DEMILITER?
- How can we find the index position of a string stored as a record in MySQL table’s column?
- Can we insert values without mentioning the column name in MySQL?

Advertisements