
- 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 “year†as a column came in a MySQL Table?
Yes, you can give the year as a column name in MySQL table since it isn’t a reserved word. Let us first create a table −
mysql> create table DemoTable ( Year int ); Query OK, 0 rows affected (0.87 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1995); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(2019); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(2016); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(2018); Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+ | Year | +------+ | 1995 | | 2019 | | 2016 | | 2018 | +------+ 4 rows in set (0.00 sec)
Following is the query to select “year” named column from MySQL table −
mysql> select year from DemoTable;
This will produce the following output −
+------+ | year | +------+ | 1995 | | 2019 | | 2016 | | 2018 | +------+ 4 rows in set (0.00 sec)
- Related Articles
- How can we insert current year automatically in a YEAR type column of MySQL table?
- Can we use MySQL keyword as alias name for a column?
- How can we use MySQL EXPORT_SET() function with column of a table?
- Can we use “When†as column name in CREATE TABLE statement?
- Can we use {} while creating a MySQL table?
- Can we add a column to a table from another table in MySQL?
- Can we use reserved word ‘index’ as MySQL column name?
- How can we remove a column from MySQL table?
- Can we use current_date() for table with column timestamp default in MySQL?
- Can we use semicolon as a MySQL DEMILITER?
- Can we use the word user for a MySQL table?
- How can we put comments in a column of existing MySQL table?
- How MySQL use YEAR data type to store year value in a table?
- How can we use LPAD() or RPAD() functions with the values in the column of a MySQL table?
- Can we use backticks with column value in MySQL?

Advertisements