- 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 4219 Articles for MySQLi
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
382 Views
To prevent a user from accessing a specific schema, you need to use delete command. Following is the syntax −DELETE FROM mysql.db WHERE Db IN("yourSpecificSchema", "yourSpecificSchema\_%") AND User = "yourUserName" AND Host = "yourHostName";Let us implement the above syntax to prevent a user from accessing a specific schema. First of all, let us display all users and host from MySQL.user table.mysql> select user, host from MySQL.user;This will produce the following output −+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
535 Views
For conditional MySQL query, you can use IF ELSE concept in stored procedure. Let us first create a table −mysql> create table DemoTable1 ( Id int ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1 values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1 values(30); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;This will produce the following output ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
194 Views
It’s a good choice to use CASE statement. Do not use UNION. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ShippingDate datetime ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ShippingDate) values('2019-04-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ShippingDate) values('2019-01-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(ShippingDate) values('2019-05-11'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(ShippingDate) values('2018-12-31'); Query OK, 1 row ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
324 Views
You can use subquery. Following is the syntax −SELECT * FROM ( SELECT * FROM yourTableName ORDER BY yourIdColumnName DESC LIMIT 3 ) anyAliasName ORDER BY yourIdColumnName;Let us first create a table −mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(100) ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientName) values('Larry'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(ClientName) values('Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ClientName) values('Bob'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(ClientName) values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ClientName) values('Carol'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(ClientName) values('Robert'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(ClientName) values('Sam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ClientName) values('Mike'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
1K+ Views
To use new line separator in group_concat() function, follow the below syntax −select group_concat(concat_ws(' ', yourColumnName1, yourColumnName2) SEPARATOR "\r") from yourTableName;Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName, LastName) values('John', 'Smith'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(FirstName, LastName) values('David', 'Miller'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName, LastName) values('John', 'Doe'); ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
114 Views
You can use CONCAT() function from MySQL for this. Let us first create a table −mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientFirstName varchar(20), ClientLastName varchar(20) ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Smith'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Miller'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('Carol', 'Taylor'); Query OK, 1 row affected (0.13 sec) mysql> insert into ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
4K+ Views
First of all, you need to enable innodb_print_all_deadlocks. Following is the syntax −set global innodb_print_all_deadlocks=1;After executing the above statement, let us execute the below syntax in order to display all deadlock logs −show engine innodb status;Let us implement the above syntax −mysql> set global innodb_print_all_deadlocks=1; Query OK, 0 rows affected (0.00 sec) mysql> show engine innodb status;This will produce the following output −+--------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Type | Name | Status ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
257 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value char(1) ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values('X'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Value) values('Y'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Value) values('X'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable(Value) values('X'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(Value) values('Y'); Query OK, 1 ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
126 Views
To set a filter for type, you can use below syntax −SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'yourDataTypeName';Let us implement the above syntax to show fields only with field type text −mysql> SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'text';This will produce the following output −+---------------------------------------------+--------------------------------+ | TABLE_NAME | COLUMN_NAME | +---------------------------------------------+--------------------------------+ | COLUMNS ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
1K+ Views
To list all rows by group, you can use GROUP_CONCAT(). Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20), Value varchar(100) ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Value) values('John', 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name, Value) values('Carol', 'Carol'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Name, Value) values('John', 'Works'); Query OK, 1 row affected (0.13 sec) mysql> insert ... Read More