- 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)
2K+ Views
For this, you can use the LIKE operator along with CONCAT() function. Let us first create a table −mysql> create table DemoTable ( Value text ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MySQL'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Is'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Relational'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Database'); Query OK, 1 row affected (0.13 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)
743 Views
To avoid displaying a certain id from a table, you need to use the operator, which is the NOT EQUAL operator. Let us first create a table −mysql> create table DemoTable7 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(40) ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable7(StudentName) values('Chris'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable7(StudentName) values('Robert'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable7(StudentName) values('Mike'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable7(StudentName) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
893 Views
For this, use LENGTH(), since if the length is 0 that would mean the string is empty. After finding, you can set it to NULL using the SET clause in the UPDATE command. Let us first create a table −mysql> create table DemoTable ( Name varchar(50) ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(''); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.12 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
125 Views
Let us first create a table −mysql> create table DemoTable ( Id int ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values(101); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(102); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(103); Query OK, 1 row affected (0.64 sec) mysql> insert into DemoTable values(104); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(105); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
980 Views
To avoid using the BETWEEN clause, you can use the AND to fetch the values between a range. Let us first create a table −mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
17K+ Views
To fetch the first alphabet from the strings, use LEFT(). This method allows you to return characters from the left of the string.Let us first see an example and create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) ); Query OK, 0 rows affected (1.03 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(FirstName) values('Adam'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(FirstName) values('Jace'); Query OK, 1 row affected (0.16 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
194 Views
To change the column name, use the AS keyword after the column name. Let us first create a table −mysql> create table DemoTable ( Id int, StudentFirstNameInCollege varchar(100) ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(101, 'Bob'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.21 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)
671 Views
For this, you can use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable ( Name varchar(40), Score int ); Query OK, 0 rows affected (1.11 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 45); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('Bob', 98); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('David', 78); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Mike', 96); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Carol', 43); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
110 Views
You can use REPLACE INTO that works like DELETE + INSERT. Let us first create a table −mysql> create table DemoTable ( Id int, FirstName varchar(50) ); Query OK, 0 rows affected (0.60 sec)Following is the query to create a unique index −mysql> alter table DemoTable add unique id_index(Id); Query OK, 0 rows affected (0.41 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert command. Since we have added duplicate records, the new record gets added i.e. replaced with the same Id with the previous record −mysql> replace into DemoTable values(100, 'Chris'); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
113 Views
To find the highest and lowest from two tables, use MAX() and MIN(). Since the results are to be displayed from two tables, you need to use UNION. Let us first create a table −mysql> create table DemoTable1 ( UniqueId int NOT NULL AUTO_INCREMENT PRIMARY KEY, Score1 int ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(Score1) values(56); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1(Score1) values(76); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1(Score1) values(65); Query OK, 1 row affected ... Read More