- 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)
206 Views
Let us first create a table −mysql> create table DemoTable1369 -> ( -> BatchId varchar(20) -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command. We have inserted numbers here separated by a slash −mysql> insert into DemoTable1369 values('19/5'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1369 values('19/78'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1369 values('19/567'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1369 values('19/1234'); Query OK, 1 row affected (0.11 sec)Display all records from the table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
377 Views
Let us first create a table −mysql> create table DemoTable1627 -> ( -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command.mysql> insert into DemoTable1627 values('John', 'Smith'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1627 values('John', 'Doe'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1627 values('Adam', 'Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1627 values('Carol', 'Taylor'); Query OK, 1 row affected (0.08 sec)Display all records from the table using ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
157 Views
For this, you can use RPAD(). Let us first create a table −mysql> create table DemoTable1626 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.37 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1626 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1626 values('Bob'); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable1626 values('Robert'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select * from DemoTable1626; This will produce the following output −+--------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
349 Views
You can use REPLACE() for this. Let us first create a table −mysql> create table DemoTable1625 -> ( -> FullName varchar(20) -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1625 values('John Doe'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1625 values('Adam Smith'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1625 values('John Smith'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1625 values('Carol Taylor'); Query OK, 1 row affected (0.14 sec)Display all records from the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
175 Views
Use IN() for select * where var== [one of many alternatives]. Let us first create a table −mysql> create table DemoTable1624 -> ( -> ClientId int, -> ClientName varchar(20) -> ); Query OK, 0 rows affected (0.39 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1624 values(101, 'Chris Brown'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1624 values(102, 'David Miller'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1624 values(103, 'John Smith'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1624 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
120 Views
Let us first create a table −mysql> create table DemoTable1623 -> ( -> StudentCode varchar(20) -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1623 values('STU-MIT-143'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1623 values('STU-MIT-10'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1623 values('STU-MIT-150'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1623 values('STU-MIT-148'); Query OK, 1 row affected (0.22 sec)Display all records from the table using select statement −mysql> select * from DemoTable1623; This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
127 Views
To search for the exact string value, use the concept of COLLATE. Let us first create a table −mysql> create table DemoTable1620 -> ( -> Subject varchar(20) -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1620 values('mysql'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1620 values('MySql'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1620 values('mYSQL'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1620 values('MySQL'); Query OK, 1 row affected (0.26 sec) mysql> insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
275 Views
To get only month name, the syntax is as follows −select date_format(yourColumnName, '%M %Y') from yourTableName;Let us first create a table −mysql> create table DemoTable1619 -> ( -> ArrivalTime datetime -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command −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 statement −mysql> select * ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
98 Views
For quicker querying, use MySQL IN() because it uses indexing internally. Let us first create a table −mysql> create table DemoTable1618 -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20), -> ClientEmailId varchar(30) -> ); Query OK, 0 rows affected (1.53 sec)Insert some records in the table using insert command:mysql> insert into DemoTable1618(ClientName, ClientEmailId) values('Chris Brown', 'Brown323@gmail.com'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1618(ClientName, ClientEmailId) values('David Miller', 'MillerDavid@gmail.com'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1618(ClientName, ClientEmailId) values('John Doe', ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
595 Views
Let us first create a table −mysql> create table DemoTable1368 -> ( -> ClientId int, -> ClientName varchar(20) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1368 values(101, 'Adam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1368 values(102, 'Bob'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1368 values(103, 'John'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1368 values(104, 'Sam'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1368 values(105, ... Read More