- 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
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
2K+ Views
To set a variable in MySQL, you need to use the SET command. Following is the syntax:set @yourVariableName:=yourValue; select *from yourTableName where yourColumnName=@yourVariableName;Let us first create a table:mysql> create table DemoTable ( Id int, FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.83 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable values(10, 'Carol', 'Taylor'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(20, 'John', 'Doe'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(30, 'John', 'Smith'); Query OK, 1 row ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
276 Views
Use LPAD() to add 0's to numbers with less than 9 digits. Let us first create a table −mysql> create table DemoTable ( Value varchar(20) ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('3646465'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values('9485757591'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('485756'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('959585'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('124'); Query OK, 1 row affected ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
885 Views
To alter row_format to dynamic in MySQL, following is the syntax:ALTER TABLE yourTableName ROW_FORMAT=DYNAMIC;Let us first create a table:mysql> create table DemoTable ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(200), CustomerAge int, CustomerAddress varchar(200) ); Query OK, 0 rows affected (0.73 sec)Let us check the description of table using DESC command:mysql> desc DemoTable;This will produce the following output:+-----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
209 Views
Here, we will use OCTET_LENGTH to check the length of a record since we want the records with length more than 1. Let us first create a table −mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserName varchar(20), UserGender varchar(20) ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(UserName, UserGender) values('John', 'M'); Query OK, 1 row affected (0.82 sec) mysql> insert into DemoTable(UserName, UserGender) values('Carol', 'Male'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(UserName, UserGender) values('Mia', 'Female'); Query OK, ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
677 Views
To delete record with the lowest id, you can use the following syntax:delete from yourTableName order by yourColumnName limit 1;Let us first create a table:mysql> create table DemoTable ( Id int, Name varchar(20) ); Query OK, 0 rows affected (0.75 sec)Following is the query to insert records in the table using insert command:mysql> insert into DemoTable values(10, 'Larry'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(100, 'Mike'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(30, 'Sam'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(90, 'Chris'); Query ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
994 Views
To select only those rows where first digit is a number from 0 to 9, use RLIKE. Following is the syntax −select *from yourTableName where yourColumnName RLIKE '^[0-9]+'Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, QuestionNumber varchar(200) ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(QuestionNumber) values('1Question'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(QuestionNumber) values('Question2'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(QuestionNumber) values('311Question'); Query OK, 1 row affected (0.13 sec) ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
2K+ Views
To compare DateTime column with only Date, you need to use the Date() method. Following is the syntax. Below, you need to date in the 'yourDateValue':select *from yourTableName where Date(yourColumnName)='yourDateValue';Let us first create a table:mysql> create table DemoTable ( ArrivalTime datetime ); Query OK, 0 rows affected (0.74 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable values('2019-01-31 02:34:56'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('2019-04-09 18:20:58'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-05-11 19:45:23'); Query OK, 1 row affected (0.13 ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
Let us first create a table −mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserName varchar(20) DEFAULT 'John' ); Query OK, 0 rows affected (0.76 sec)Let us check the description of table −mysql> desc DemoTable;This will produce the following output −+----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+----------------+ | UserId | int(11) | NO | PRI | NULL ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
5K+ Views
To add a new enum column to an existing MySQL table, you can use ALTER command. Following is the syntax:ALTER TABLE yourTableName ADD yourColumnName ENUM('yourValue1', 'yourValue2’....N) NOT NULL;Let us first create a table:mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(200), StudentAge int ); Query OK, 0 rows affected (0.62 sec)Check the description of table using DESC command:mysql> DESC DemoTable;This will produce the following output:+-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | StudentId ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
389 Views
Yes, you can use stored procedure to insert into two tables in a single query. Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(20) ); Query OK, 0 rows affected (0.56 sec)Here is the query to create second table −mysql> create table DemoTable2 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20), ClientAge int ); Query OK, 0 rows affected (0.76 sec)Following is the query to create stored procedure to insert into two tables created above −mysql> DELIMITER // mysql> CREATE PROCEDURE ... Read More