- 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
Found 4378 Articles for MySQL
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
160 Views
To display, use DESC command or information_schema.columns. Let us first create a table and set options −mysql> create table DemoTable ( Color SET('RED', 'GREEN', 'BLUE', 'YELLOW') ); Query OK, 0 rows affected (0.47 sec)Case 1Here is the query to get the list of available options for SET using the DESC command −mysql> desc DemoTable;This will produce the following output −+-------+------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
821 Views
To insert random numbers, use RAND() function from MySQL. Let us first create a table −mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.08 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-------+ | Value | +-------+ | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
95 Views
To delete a record in the required way, the syntax is as follows −delete from yourTableName where yourTableName .yourColumnName=yourValue;Let us first create a table −mysql> create table DemoTable ( StudentName varchar(100), StudentAge int ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 21); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Robert', 20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('David', 22); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Mike', 24); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
138 Views
Let us first create a table −mysql> create table DemoTable( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100), AdmissionDate date ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, AdmissionDate) values('Chris', '2019-11-21'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Mike', '2019-03-11'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Sam', '2018-04-01'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Carol', '2019-05-01'); Query OK, 1 row affected (0.40 sec)Display all records from the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
637 Views
Let us first create a table −mysql> create table DemoTable1 ( Name varchar(100), Gender ENUM('MALE', 'FEMALE') ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values('Chris', 'Male'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1 values('Emma', 'Female'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;This will produce the following output −+-------+--------+ | Name | Gender | +-------+--------+ | Chris | MALE | | Emma | FEMALE | +-------+--------+ 2 rows in set ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
218 Views
Let us first create a table −mysql> create table DemoTable ( Name varchar(100), Age int ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 23); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('David', 55); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Bob', 53); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Mike', 54); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values('Sam', 55); Query OK, 1 row affected (0.18 sec)Display all records ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
503 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(FirstName) values('Robert'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(FirstName) values('Robert'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.11 sec) mysql> insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
98 Views
Let us first create a table −mysql> create table DemoTable ( FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Adam', 'Smith'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('David', 'Miller'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
To update a field if it is null, use IS NULL property along with the UPDATE command. Let us first create a table −mysql> create table DemoTable ( StudentScore int ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(56); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
228 Views
To insert values from the first table to another table using two SELECT statements, use SUBQUERY. This will allow you to use only a single MySQL query to get the result in the second table. Let us first create a table −mysql> create table DemoTable1 ( Name varchar(100), Score int ); Query OK, 0 rows affected (1.30 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values('Chris', 45); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1 values('Bob', 78); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1 values('David', 98); ... Read More