- 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)
1K+ Views
The Database Error #1064 may occur due to incorrect syntax. For example, let’s say we are creating the below table −mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserName varchar(100), UserAge int, UserAddress varchar(200), UserCountryName varchar(100) , isMarried boolean, );This will produce the following output i.e. error −ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
160 Views
You cannot give MySQL stored procedure parameter with @ in the beginning. You can give @ sign in user-defined variables.Following is the syntax −SET @yourVariableName=yourValue;Let us implement the above syntax to correctly place @sign −mysql> DELIMITER // mysql> CREATE PROCEDURE declare_Variable(IN StudentName varchar(100)) BEGIN SET @Name=StudentName; SELECT @Name; END // Query OK, 0 rows affected (0.12 sec) mysql> DELIMITER ;Now you can call stored procedure with the help of CALL command −mysql> call declare_Variable('John Smith');This will produce the following output −+------------+ | @Name | +------------+ | John Smith | +------------+ 1 row in set (0.00 sec) Query OK, 0 rows affected, 1 warning (0.03 sec)
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
120 Views
Yes, use ON DUPLICATE KEY UPDATE. Let us first create a table −mysql> create table DemoTable(Id int NOT NULL PRIMARY KEY, Number int); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 190) ON DUPLICATE KEY UPDATE Number=Number+10; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(2, 130) ON DUPLICATE KEY UPDATE Number=Number+10; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(1, 190) ON DUPLICATE KEY UPDATE Number=Number+10; Query OK, 2 rows affected (0.14 sec) mysql> insert into DemoTable values(2, 130) ON DUPLICATE ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
331 Views
For this, use IFNULL(). Let us first create a table −mysql> create table DemoTable (Value int); Query OK, 0 rows affected (1.02 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.13 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)
364 Views
To set special characters for a password, use the following syntax −create user 'yourUserName'@'yourHostName' identified by 'yourSpecialCharacterPassword';Let us implement the above syntax in order to create a new user and set password with special characters −mysql> create user 'Mike'@'localhost' identified by 'Mike_123456'; Query OK, 0 rows affected (0.35 sec)Let us check the table where MySQL user and host is stored −mysql> select user, host from MySQL.user;This will produce the following output. The new user created successfully −+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
367 Views
Yes, we can remove a primary key using the DROP in MySQL. Following is the syntax −alter table yourTableName drop primary key;Let us first create a table −mysql> create table DemoTable ( UserId int NOT NULL PRIMARY KEY ); Query OK, 0 rows affected (0.58 sec)Following is the query to check the description of table −mysql> desc DemoTable;This will produce the following output displaying the Primary Key −+--------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------+------+-----+---------+-------+ | UserId | int(11) | NO | PRI ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
6K+ Views
To get max(id), use MAX() method in MySQL. Following is the syntax −select MAX(yourColumnName) AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable710 (Id int); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable710 values(1001); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable710 values(2001); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable710 values(1998); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable710 values(1789); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable710 values(1678); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
435 Views
Let us first create a table −mysql> create table DemoTable709 (Amount int); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable709 values(100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable709 values(560); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable709 values(7800); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable709 values(1020); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable709;This will produce the following output -+--------+ | Amount | +--------+ | 100 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Let us first create a table −mysql> create table DemoTable708 ( CustomerName varchar(100), ShippingDate date ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable708 values('John', '2019-01-21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable708 values('Chris', '2019-03-24'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable708 values('Robert', '2019-04-26'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable708 values('David', '2019-07-22'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable708;This will produce the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
142 Views
Let us first create a table −mysql> create table DemoTable707 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100), StudentMarks int ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values('John', 45); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values(NULL, 65); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values('Chris', 78); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values(NULL, 89); Query OK, 1 row affected (0.19 sec) mysql> insert into ... Read More