- 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
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
74 Views
To check this, you can use SHOW command. The syntax is as follows −show grants\GLet us implement the above syntax to display the permissions you have −mysql> SHOW GRANTS\GThis will produce the following output −*************************** 1. row *************************** Grants for root@%: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`%` WITH GRANT OPTION *************************** 2. row *************************** Grants for root@%: ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
308 Views
In order to order by 0 first and then largest, you can use the below syntax −select *from yourTableName order by yourColumnName=0 DESC, yourColumnName DESC;Let us first create a table −mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.65 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(90); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.12 ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
766 Views
Let us first create a table −mysql> create table DemoTable ( UserId int, UserName varchar(10), UserAge int ); Query OK, 0 rows affected (0.73 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(101, 'Chris', 23); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(102, 'Robert', 33); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(103, 'David', 25); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(104, 'Carol', 35); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(105, 'Bob', 29); Query OK, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
423 Views
Use MySQL JOIN to select MySQL rows where column contains same data in more than one record. Let us first create a table −mysql> create table DemoTable ( UserId int, UserName varchar(20) ); Query OK, 0 rows affected (0.54 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(10, 'John'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(11, 'Sam'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(12, 'Larry'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(13, 'David'); Query OK, 1 row affected (0.17 ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
971 Views
You can use INFORMATION_SCHEMA.TABLES and AVG_ROW_LENGTH to query average row length in MySQL −SELECT AVG_ROW_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ‘yourTableName’;Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ); Query OK, 0 rows affected (0.90 sec)Insert records in the table using insert command −mysql> insert into DemoTable(StudentName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(StudentName) values('Larry'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(StudentName) values('Sam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentName) values('Mike'); Query OK, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
824 Views
To prevent duplicate entry, add constraint UNIQUE. Let us first create a table −mysql> create table DemoTable ( Id int, Name varchar(100) ); Query OK, 0 rows affected (0.79 sec)Here is the query to prevent MySQL double insert using UNIQUE −mysql> alter table DemoTable add constraint id_NameUnKey UNIQUE(Id, Name); Query OK, 0 rows affected (0.82 sec) Records: 0 Duplicates: 0 Warnings: 0Insert records in the table using insert command. When we will try to the same record again, then the “Duplicate entry” error will be visible −mysql> insert into DemoTable values(11, 'John'); Query OK, 1 row affected (0.18 ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
You can use LPAD() from MySQL for this. Let us first create a table −mysql> create table DemoTable ( FullName varchar(100) ); Query OK, 0 rows affected (0.81 sec)Insert records in the table using insert command −mysql> insert into DemoTable values('John Smith'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('David Miller'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Sam Williams'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Carol Taylor'); Query OK, 1 row affected (0.47 sec)Display records from the table using select command −mysql> select *from DemoTable;This ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
852 Views
To select all except the first character in a string, you can use SUBSTR() method. Let us first create a table −mysql> create table DemoTable ( FirstName varchar(20) ); Query OK, 0 rows affected (0.63 sec)Insert records in the table using insert command −mysql> insert into DemoTable values('Larry'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.14 sec)Display records from the table using select command −mysql> ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
783 Views
You need to use backticks around the table name where the table name has blank space. Let us first create a table. Here, we have used backtick −mysql> create table `Demo Table138` ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Price int ); Query OK, 0 rows affected (0.47 sec)Insert records in the table using insert command −mysql> insert into `Demo Table138`(Price) values(450); Query OK, 1 row affected (0.18 sec) mysql> insert into `Demo Table138`(Price) values(499); Query OK, 1 row affected (0.16 sec) mysql> insert into `Demo Table138`(Price) values(199); Query OK, 1 row affected (0.17 sec) mysql> insert into ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
191 Views
You can use aggregate function AVG() for this. Let us first create a table −mysql> create table DemoTable ( Value1 int, Value2 int, Value3 int ); Query OK, 0 rows affected (0.54 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(10, 20, 30); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(13, 15, 18); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(21, 31, 41); Query OK, 1 row affected (0.21 sec)Display records from the table using select command −mysql> select *from DemoTable;This will produce the following ... Read More