- Trending Categories
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 the word user for a MySQL table?
You cannot use “user” for a MySQL table because it is a reserved word in MySQL. You can change the name from user to users or something else or you can use backticks around the user word.
The word user can be used to create a user or can select a user list from the MySQL database.
Let us first create a table. Here, we have used the table name users −
mysql> create table users -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20), -> UserAge int -> ); Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into users(UserName,UserAge) values('Chris Brown',28); Query OK, 1 row affected (0.17 sec) mysql> insert into users(UserName,UserAge) values('John Doe',31); Query OK, 1 row affected (0.18 sec) mysql> insert into users(UserName,UserAge) values('John Smith',26); Query OK, 1 row affected (0.17 sec) mysql> insert into users(UserName,UserAge) values('David Miller',27); Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select *from users;
This will produce the following output −
+--------+--------------+---------+ | UserId | UserName | UserAge | +--------+--------------+---------+ | 1 | Chris Brown | 28 | | 2 | John Doe | 31 | | 3 | John Smith | 26 | | 4 | David Miller | 27 | +--------+--------------+---------+ 4 rows in set (0.00 sec)
Advertisements