- 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
223 Views
To reserve MySQL auto-incremented IDs, the syntax is as follows −START TRANSACTION; insert into yourTableName values(), (), (), (); ROLLBACK; SELECT LAST_INSERT_ID() INTO @anyVariableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table reservingAutoIncrementDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command. The query is as follows −mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> insert into reservingAutoIncrementDemo values(), (), (), (); Query ... Read More
57 Views
The set+0 converts the set value to integer. Let us see an example by creating a table −mysql> create table SetZeroDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> TechnicalSkills set('C', 'Spring Framework /Hibernate', 'Python', 'Django Framework', 'Core Java') NOT NULL -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into SetZeroDemo(TechnicalSkills) -> values('C, Spring Framework /Hibernate, Python, Django Framework, Core Java'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement. The ... Read More
2K+ Views
The DECLARE syntax must between BEGIN and END. The syntax is as follows −BEGIN DECLARE yourVariableName1 dataType, DECLARE yourVariableName2 dataType, . . . . ENDHere is the query to avoid DECLARE syntax error in MySQL −mysql> DELIMITER // mysql> create procedure declare_Demo() -> BEGIN -> DECLARE Name varchar(100); -> SET Name: ='John'; -> SELECT Name; -> END -> // Query OK, 0 rows affected (0.17 sec) mysql> DELIMITER ;Call the stored procedure with the help of CALL command. The syntax is as follows −CALL yourStoredProcedureName();The query is as follows −mysql> call declare_Demo();The following is ... Read More
346 Views
To check replication type, you can use SHOW GLOBAL VARIABLES command. The syntax is as follows −SHOW GLOBAL VARIABLES LIKE 'binlog_format';The above syntax returns either ROW, MIXED or STATEMENT. The default resultant is ROW.Now you can implement the above syntax to check replication type. The query is as follows −mysql> SHOW GLOBAL VARIABLES LIKE 'binlog_format';Here is the output −+---------------+-------+ | Variable_name | Value | +---------------+-------+ | binlog_format | ROW | +---------------+-------+ 1 row in set (0.10 sec)Here is the query to switch from ROW to STATEMENT −mysql> SET GLOBAL binlog_format = 'STATEMENT'; Query OK, 0 rows affected (0.04 ... Read More
197 Views
To select accumulated column, let us first create a demo table. The query to create a table is as follows −mysql> create table accumulatedDemo -> ( -> Value int -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into accumulatedDemo values(10); Query OK, 1 row affected (0.21 sec) mysql> insert into accumulatedDemo values(15); Query OK, 1 row affected (0.09 sec) mysql> insert into accumulatedDemo values(20); Query OK, 1 row affected (0.13 sec) mysql> insert into accumulatedDemo values(25); Query OK, 1 row affected ... Read More
278 Views
The SELECT INTO equivalent is CREATE TABLE AS SELECT statement. The syntax is as follows −CREATE TABLE yourNewTableName AS SELECT *FROM yourTableName;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table selectIntoEquivalentDemo -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20), -> ClientAge int -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into selectIntoEquivalentDemo(ClientName, ClientAge) values('Larry', 34); Query OK, 1 row affected (0.13 ... Read More
252 Views
To find/replace string in fields, the syntax is as follows −update yourTableName set yourColumnName =REPLACE(yourColumnName, yourOldValue, yourNewValue);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table FindReplaceDemo -> ( -> FileId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FileDirectory text -> ); Query OK, 0 rows affected (0.92 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into FindReplaceDemo(FileDirectory) values('C://User//MySQL'); Query OK, 1 row affected (0.19 sec) mysql> insert into FindReplaceDemo(FileDirectory) values('D://WebsiteImage//image1.jpg'); Query OK, ... Read More
485 Views
Adding an index on column of int type is a good choice to run your query faster whenever your table has lots of records.If your table has less records then it is not a good choice to use index on column of int type.To understand the concept, let us create a table. The query to create a table is as follows −mysql> create table indexOnIntColumnDemo -> ( -> UserId int, -> UserName varchar(20), -> UserAge int, -> INDEX(UserId) -> ); Query OK, 0 rows affected (0.85 sec)Now check the description of table −mysql> desc ... Read More
124 Views
You can use DROP INDEX for this. The syntax is as follows −alter table yourTablename drop index yourUniqueName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table removeUniquenessConstraint -> ( -> Id int, -> Name varchar(100), -> Age int, -> isGreaterThan18 bool, -> UNIQUE(Id, isGreaterThan18) -> ); Query OK, 0 rows affected (0.69 sec)Now check the details of table with the help of SHOW CREATE command. The query is as follows −mysql> show create table removeUniquenessConstraint;Here is the output −+----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ... Read More
252 Views
Let us first create a demo table −mysql> create table BulkChangeDemo -> ( -> CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CustomerName varchar(20), -> isEducated boolean -> ); Query OK, 0 rows affected (1.47 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into BulkChangeDemo(CustomerName, isEducated) values('Larry', true); Query OK, 1 row affected (0.09 sec) mysql> insert into BulkChangeDemo(CustomerName, isEducated) values('John', false); Query OK, 1 row affected (0.16 sec) mysql> insert into BulkChangeDemo(CustomerName, isEducated) values('Carol', false); Query OK, 1 row affected (0.25 sec) mysql> insert into BulkChangeDemo(CustomerName, ... Read More