- 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
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
157 Views
Following is the syntax −select table_name, create_time from information_schema.TABLES where table_schema = 'yourDataBaseName' order by CREATE_TIME desc limit 1;Let us create the first table (Time: 2019-06-10 16:40:51) −mysql> create table DemoTable1 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> ); Query OK, 0 rows affected (0.59 sec)We will now create the second table, let’s say after 5 minutes −mysql> create table DemoTable2 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> ); Query ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
179 Views
To get the current size of a table, use the following that will display details about a table including the size −show table status like ‘yourTableName’\GLet us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CustomerName varchar(20), -> CustomerAge int, -> CustomerCountryName varchar(20) -> ); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerName, CustomerAge, CustomerCountryName) values('John', 24, 'US'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(CustomerName, CustomerAge, CustomerCountryName) ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
91 Views
To work with auto incrementing column, you can set it as AUTO_INCREMENT while creating the table.Let us first create a table. Here, we have set the Id field as column since that would be our auto increment column −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.71 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.14 sec) mysql> insert into DemoTable(FirstName, LastName) values('Chris', 'Brown'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(FirstName, LastName) values('Carol', 'Taylor'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+----+-----------+----------+ | Id | FirstName | LastName | +----+-----------+----------+ | 1 | John ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
157 Views
For this, use ORDER BY clause. The current date is as follows −mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-09 21:08:16 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> DueDate datetime -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(DueDate) values('2019-06-12'); Query OK, 1 row affected (0.24 sec) ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
522 Views
For concatenating a string field, use CONCAT() function. Let us first create a table −mysql> create table DemoTable -> ( -> SequenceId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentId varchar(100) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentId) values('STU'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentId) values('STU1'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+------------+-----------+ | SequenceId | StudentId | +------------+-----------+ | 1 ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
302 Views
To get age from DOB, you can use the TIMESTAMPDIFF() function. Following is the syntax −select TIMESTAMPDIFF(YEAR, yourColumnName, CURRENT_DATE) AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> DateOfBirth datetime -> ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(DateOfBirth) values('1998-06-04 12:30:00'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(DateOfBirth) values('2000-01-31 04:10:20'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(DateOfBirth) values('2010-12-01 03:50:45'); ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
373 Views
You can use UNION ALL for this.Let us get list 10, 20, 30, 40, 50 as a table with UNION ALL −mysql> select 10 Number UNION ALL select 20 Number UNION ALL select 30 Number UNION ALL select 40 Number UNION ALL select 50 Number;Output+--------+ | Number | +--------+ | 10 | | 20 | | 30 | | 40 | | 50 | +--------+ 5 rows in set (0.00 sec)Let us see another example. To get the list 1,2,3 as a table, use the below query −mysql> SELECT 1 a UNION ALL SELECT 2 a UNION ALL SELECT 3 a;Output+---+ | a | +---+ | 1 | | 2 | | 3 | +---+ 3 rows in set (0.00 sec)
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
118 Views
For this, you can use LEAST(). Following is the syntax −select least(yourColumnName, yourMaxValue) from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(50); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(201); Query OK, 1 row affected (0.12 sec) ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
232 Views
For this, you can use DATEDIFF() function. The current date time is as follows −mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-09 19:15:56 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable -> ( -> ShippingDate datetime -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-06-01'); Query OK, 1 row affected (0.19 sec) ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
92 Views
To count where more than three column values are true, you can use WHERE clause. Let us first create a table −mysql> create table DemoTable -> ( -> isMarried boolean, -> isActive boolean, -> isMember boolean, -> isOn boolean -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(true, false, true, false); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(false, false, false, false); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(true, true, ... Read More