- 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)
238 Views
No, we cannot. To still work it out, use backticks around the field name. Let us first create a table with column name with asterisk, `Name*` −mysql> create table DemoTable -> ( -> `Name*` varchar(20) -> ); Query OK, 0 rows affected (2.03 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(`Name*`) values('Chris Brown'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(`Name*`) values('David Miller'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(`Name*`) values('John Doe'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(`Name*`) values('John Smith'); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
79 Views
For this, you can use SOUND along with the LIKE operator. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values('Adam'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable values('Johm'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('SAMSUNG'); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
545 Views
To replace a record that doesn’t exist, use the COALESCE in MySQL. The COALESCE would help in substituting the NULL values. Let us first create a table −mysql> create table DemoTable -> ( -> Code varchar(20) -> ); Query OK, 0 rows affected (1.64 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('45'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('78'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
106 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(201, 'Chris Brown'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(110, 'John Doe'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values(101, 'Adam Smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(345, 'Carol Taylor'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(135, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
75 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Value1 int, -> Value2 int -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(78, 89); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(19, null); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(null, 0); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(null, 95); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
348 Views
For this, you can use CASE WHEN statement. Let us first create a table −mysql> create table DemoTable -> ( -> FirstName varchar(20), -> Score int -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 46); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('John', 78); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('John', 69); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Chris', 78); Query OK, 1 row affected (0.12 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
101 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(FirstName) values('Adam'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(FirstName) values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(FirstName) values('Mike'); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
320 Views
To find the difference between two datetime values, you can use TIMESTAMPDIFF(). Let us first create a table −mysql> create table DemoTable -> ( -> DueDatetime1 datetime, -> DueDatetime2 datetime -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-10-26 19:49:00', '2019-10-26 17:49:00'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('2019-10-26 08:00:00', '2019-10-26 13:00:00'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2019-10-26 06:50:00', '2019-10-26 12:50:00'); Query OK, 1 row affected (0.68 sec)Display all records from the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
113 Views
Let us first create a table −mysql> create table DemoTable -> ( -> DueDate date ->); Query OK, 0 rows affected (2.11 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-01-21'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2018-12-31'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values('2018-12-30'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values('2017-02-26'); Query OK, 1 row affected (0.47 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+------------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
343 Views
Let us first create a table −mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (1.07 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName) values('Chris'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(StudentName) values('Robert'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(StudentName) values('David'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(StudentName) values('Mike'); Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement ... Read More