- 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
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
397 Views
The current date and time is as follows −mysql> select now();OutputThis will produce the following output −+---------------------+ | now() | +---------------------+ | 2019-06-15 12:24:06 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable ->( -> ArrivalDate datetime -> ); Query OK, 0 rows affected (1.15 sec)Insert some records in the table using insert command. Here, we are adding multiple intervals to the DATE_ADD() method −mysql> insert into DemoTable values(DATE_ADD(DATE_ADD(NOW(), INTERVAL 6 MONTH), INTERVAL 1 YEAR)); Query OK, 1 row affected (0.13 sec) ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
822 Views
For this, you can use GROUP BY clause along with IN(). Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('John'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(Name) values('Chris'); Query ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
53K+ Views
The ERROR 1064 (42000) mainly occurs when the syntax isn’t set correctly i.e. error in applying the backtick symbol or while creating a database without them can also create an error, if you will use hyphen in the name, for example, Demo-Table will result in ERROR 1064 (42000).To remove the error, you need to use backtick around the database name properly or use nothing. Following is the syntax wherein we haven’t used the backtick. This works correctly −create database yourDatabaseName;Since adding hyhen to the database name will result in an error. Let us implement it while creating the database name ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
53 Views
You can use DISTINCT along with COUNT(). Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Score int -> ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 90); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(10, 190); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(11, 230); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(11, 130); Query OK, 1 row affected (0.17 ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
90 Views
Let’s say we are creating a database “web” −mysql> SHOW CREATE DATABASE web;This will produce the following output displaying the default charset as well −+----------+-----------------------------------------------------------------------------------------+ | Database | Create Database | +----------+-----------------------------------------------------------------------------------------+ | web | CREATE DATABASE `web` /*!40100 DEFAULT CHARACTER SET utf8 COLLATEutf8_unicode_ci */ | +----------+-----------------------------------------------------------------------------------------+ 1 row in set (0.03 sec)If you want to know ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
945 Views
For this, you can create a stored procedure. Let us first create a table.mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.55 sec)Following is the query to create a stored procedure to auto insert values to a table from range 10 to 20 −mysql> DELIMITER // mysql> CREATE PROCEDURE AutoInsertValuesToTable() -> BEGIN -> DECLARE startingRange INT DEFAULT 10; -> WHILE startingRange INSERT DemoTable(Value) VALUES (startingRange ); -> SET startingRange = startingRange + 1; -> ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
487 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Number int -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Number) values(10); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Number) values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Number) values(30); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Number) values(40); Query OK, 1 row affected (0.14 sec) Display all records from ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
502 Views
Use i.e. not equal in MySQL to exclude a specific row from a table. Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> FirstName varchar(100) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 'John'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(2, 'Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(3, 'Robert'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
612 Views
For this, you can use GROUP BY HAVING clause. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Subject varchar(100) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Subject) values('MySQL'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Subject) values('MongoDB'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Subject) values('MySQL'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Subject) values('Java'); Query OK, 1 ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
954 Views
For this, you can use concat() function from MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Subject varchar(100) -> ); Query OK, 0 rows affected (17.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Subject) values('John', 'MySQL'); Query OK, 1 row affected (1.19 sec) mysql> insert into DemoTable(Name, Subject) values('Chris', 'SQL Server'); Query OK, 1 row affected (0.88 sec) mysql> insert into DemoTable(Name, Subject) values('Robert', 'MongoDB'); Query OK, 1 row affected ... Read More