- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
Advertisements