- 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)
422 Views
For this, you can use IS NOT NULL property. Let us first create a table −mysql> create table DemoTable1 ( DueDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values('2019-09-10'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1 values(NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1 values('2019-11-10'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1; This will produce the following output −+------------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
550 Views
To increase precision with division, use MySQL CAST(). Let us first create a table −mysql> create table DemoTable1823 ( Value int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1823 values(1); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1823 values(2); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1823 values(3); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1823;This will produce the following output −+-------+ | Value ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
559 Views
Let us first create a table −mysql> create table DemoTable1822 ( Amount int, DueDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1822 values(1000, '2019-10-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1822 values(500, '2019-11-30'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1822 values(700, '2018-11-30'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1822;This will produce the following output −+--------+------------+ | Amount | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
70 Views
No, the query won’t work. Let’s create the same scenario and check the error −mysql> create table DemoTable1821 ( Id int, FirstName varchar, LastName varchar ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', LastName varchar )' at line 4To remove the above error, you need to give the size of varchar(10). Let us first create a table −mysql> create table DemoTable1821 ( Id int, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
147 Views
For this, you can use DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1820 ( AdmissionDate varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1820 values('20/10/2019'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1820 values('19/12/2018'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1820 values('16/04/2017'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1820;This will produce the following output −+---------------+ | AdmissionDate | +---------------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
66 Views
For this, you can use COUNT() along with GROUP BY MONTH(). To match with the current date, use CURRENT_DATE(). The current date is as follows −mysql> select curdate() ; +------------+ | curdate() | +------------+ | 2019-11-30 | +------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable1819 ( Name varchar(20), RegisteringDate datetime ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1819 values('Chris', '2019-11-29 12:30:34'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1819 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
266 Views
To count the same value of each row, use COUNT(*) along with GROUP BY clause. Let us first create a table −mysql> create table DemoTable1818 ( Id int, Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1818 values(10, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1818 values(11, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1818 values(11, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1818 values(12, 'Chris'); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
936 Views
To pass multiple ids to single parameter, use FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable1817 ( EmployeeName varchar(20), CountryName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1817 values('Chris', 'AUS'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1817 values('David', 'UK'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1817 values('Bob', 'US'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1817;This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
392 Views
Following is the syntax to match date with date() function and updating a column −update yourTableName set yourColumnName=yourValue where date(yourColumnName)=curdate();Let us first create a table −mysql> create table DemoTable1816 ( Name varchar(20), JoiningDate datetime ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1816 values('Chris', '2019-11-29 12:34:50'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1816 values('David', '2019-11-30 11:00:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1816 values('Mike', '2018-11-30 10:20:30'); Query OK, 1 row affected (0.00 sec)Display ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
274 Views
To randomly select, use ORDER BY RAND(). To select only 2 values, use LIMIT 2 in MySQL. Let us first create a table −mysql> create table DemoTable1815 ( Question text ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1815 values('What is your name?'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1815 values('What is your college name?'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1815 values('What is your nick name?'); Query OK, 1 row affected (0.00 sec) mysql> ... Read More