- 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
237 Views
Let us first create a table −mysql> create table DemoTable722 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentAge int ); Query OK, 0 rows affected (1.84 sec)Insert some records in the table using insert command −mysql> insert into DemoTable722(StudentName, StudentAge) values('Chris Brown', 23) ; Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable722(StudentName, StudentAge) values('John Smith', 21); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable722(StudentName, StudentAge) values('David Miller', 22); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable722(StudentName, StudentAge) values('Adam Smith', 20); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
102 Views
Yes, SELECT with an IF/ELSE is possible in MySQL.Let us first create a table −mysql> create table DemoTable721 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100), Marks int, CountryName varchar(100) ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable721(FirstName, Marks, CountryName) values('Chris', 56, 'US'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable721(FirstName, Marks, CountryName) values('Robert', 78, 'UK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable721(FirstName, Marks, CountryName) values('Mike', 45, 'AUS'); Query OK, 1 row affected (0.16 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
314 Views
Let us first create a table −mysql> create table DemoTable ( Code varchar(100) ); Query OK, 0 rows affected (1.16 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('100-677-9876'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('100-677-9876-John'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('David-100-677-9876'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------------------+ | Code | +--------------------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
87 Views
At first, to use reserved words, it should be set with backticks like −`from` `to`Since you want to select the column names set with backtick as shown above, you need to implement the following −select `to`, `from` from yourTableName;Let us first create a table with column names as from and to with backticks −mysql> create table DemoTable720 ( `from` date, `to` date ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable720 values('2019-01-21', '2019-07-23'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable720 values('2017-11-01', '2018-01-31'); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
477 Views
Use trigger BEFORE INSERT on the table to prevent having a zero value in a MySQL field. Let us first create a table −mysql> create table DemoTable(Value int); Query OK, 0 rows affected (0.85 sec)Let us create a trigger to prevent having a zero value in a MySQL field −mysql> DELIMITER // mysql> create trigger preventing_to_insert_zero_value before insert on DemoTable for each row begin if(new.Value = 0) then SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'You can not provide 0 value'; END if; end // Query OK, 0 rows affected (0.34 sec) mysql> DELIMITER ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
557 Views
The slash means division ( /) in MySQL query. This can be used to divide two numbers. Here, we will see an example to divide numbers from two columns and display result in a new column.Let us first create a table −mysql> create table DemoTable719 ( FirstNumber int, SecondNumber int ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable719 values(20, 10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable719 values(500, 50); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable719 values(400, 20); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
For this, you can use NOT IN() function.Let us first create a table −mysql> create table DemoTable718 ( Id int, FirstName varchar(100), Age int ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable718 values(101, 'Chris', 26); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable718 values(102, 'Robert', 24); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable718 values(103, 'David', 27); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable718 values(104, 'Mike', 28); Query OK, 1 row affected (0.19 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
711 Views
Let us first create a table −mysql> create table DemoTable717 ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserPassword int ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable717(UserPassword) values(1454343); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable717(UserPassword) values(674654); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable717(UserPassword) values(989883); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable717(UserPassword) values(909983); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable717;This will produce ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
364 Views
Let us first create a table −mysql> create table DemoTable716 ( Id varchar(100), Value1 int, Value2 int, Value3 int ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable716 values('100', 45, 86, 79); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable716 values('101', 67, 67, 99); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable716 values('102', 77, 57, 98); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable716 values('103', 45, 67, 92); Query OK, 1 row affected (0.16 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
81 Views
For this, you can use ORDER BY IF(CAST()). Let us first create a table −mysql> create table DemoTable(EmployeeCode varchar(100)); Query OK, 0 rows affected (1.17 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('190'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('100'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('120'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------------+ ... Read More