- 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)
70 Views
For this, let us see an example and first create a −mysql> create table DemoTable1409 -> ( -> FirstName varchar(20), -> UNIQUE KEY UN_FirstName(FirstName) -> ); Query OK, 0 rows affected (0.79 sec)Following is the query to add duplicate varchar −mysql> alter table DemoTable1409 drop index UN_FirstName; Query OK, 0 rows affected (0.40 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert −mysql> insert into DemoTable1409 values('Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1409 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1409 values('David'); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
731 Views
Let us first create a −mysql> create table DemoTable1407 -> ( -> Name text -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert −mysql> insert into DemoTable1407 values('John, Bob'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1407 values('Carol, David, Adam'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1407 values('Mike, Sam, Chris'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select −mysql> select * from DemoTable1407;This will produce the following output −+------------------+ | Name ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
74 Views
Let us see an example and create a −mysql> create table DemoTable1406 -> ( -> Value int -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert −mysql> insert into DemoTable1406 values(10); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1406 values(50); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1406 values(40); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1406 values(30); Query OK, 1 row affected (0.11 sec)Display all records from the table using select −mysql> select * from DemoTable1406;This will produce the following ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
64 Views
To remove unnecessary whitespaces, use TRIM() in MySQL. Let us first create a −mysql> create table DemoTable1405 -> ( -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert −mysql> insert into DemoTable1405 values(' Chris', ' Brown '); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1405 values('David ', ' Miller '); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1405 values(' Carol ', ' Taylor '); Query OK, 1 row affected (0.19 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
379 Views
Let us first create a −mysql> create table DemoTable1619 -> ( -> ArrivalTime datetime -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert −mysql> insert into DemoTable1619 values(now()); Query OK, 1 row affected (0.40 sec) mysql> insert into DemoTable1619 values(curdate()); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1619 values('2019-12-31'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select −mysql> select * from DemoTable1619;This will produce the following output −+---------------------+ | ArrivalTime | +---------------------+ | 2019-10-20 15:02:12 | | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
193 Views
For this, you can use INET_ATON(). Let us first create a −mysql> create table DemoTable1404 -> ( -> IpAddress varchar(40) -> ); Query OK, 0 rows affected (1.02 sec)Insert some records in the table using insert −mysql> insert into DemoTable1404 values('192.168.120.0'); Query OK, 1 row affected (0.43 sec) mysql> insert into DemoTable1404 values('192.168.120.20'); Query OK, 1 row affected (0.60 sec) mysql> insert into DemoTable1404 values('224.0.0.0'); Query OK, 1 row affected (0.42 sec)Display all records from the table using select −mysql> select * from DemoTable1404;This will produce the following output −+----------------+ | IpAddress | +----------------+ | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
322 Views
You cannot use UPDATE command with ORDER BY clause, but you can use SELECT statement with ORDER BY DESC.Let us first create a −mysql> create table DemoTable1403 -> ( -> DueDate timestamp -> ); Query OK, 0 rows affected (1.26 sec)Insert some records in the table using insert −mysql> insert into DemoTable1403 values('2019-09-29'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1403 values('2016-02-21'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1403 values('2018-01-31'); Query OK, 1 row affected (0.65 sec) mysql> insert into DemoTable1403 values('2017-12-01'); Query OK, 1 row affected (0.27 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
113 Views
For this, you can use substring() function in MySQL. For conditions, use MySQL CASE statement. Let us first create a −mysql> create table DemoTable1402 -> ( -> EmployeeName varchar(40) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert −mysql> insert into DemoTable1402 values('Adam Smith'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1402 values('Chris Brown'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1402 values('David Miller'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1402 values('Carol Taylor'); Query OK, 1 row affected (0.10 sec)Display ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
121 Views
Backticks would work if written correctly as in the below syntax −update `yourTableName` set `yourTableName`.`yourColumnName`='yourNewValue' where yourCondition;Let us first create a −mysql> create table `DemoTable_1401` -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert −mysql> insert into `DemoTable_1401` values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into `DemoTable_1401` values('David'); Query OK, 1 row affected (0.10 sec) mysql> insert into `DemoTable_1401` values('Bob'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select −mysql> select * from `DemoTable_1401`;This will produce the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
Each relation may have one or more candidate key. One of these candidate keys is called Primary Key. Each candidate key qualifies for Primary Key. Therefore, candidates for Primary Key is called Candidate Key. To implement candidate key in MySQL, set more than one column as unique key. These keys would qualify for candidate key as in the below syntax −alter table yourTableName add unique key anyName(yourColumnName1, yourColumnName2);Let us first create a −mysql> create table DemoTable1400 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(40), -> Age int -> ); Query ... Read More