- 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)
232 Views
Yes, the AUTO_INCREMENT in MySQL will be signed (Positive and Negative Value both) by default.Let us first create a table −mysql> create table DemoTable -> ( -> MyNumber int AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command. Here, we have set negative values as well for AUTO_INCREMENT column −mysql> insert into DemoTable values() ; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(-100); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(-300); Query OK, 1 row affected ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
1K+ Views
To order an alphanumeric column with values like “100X, “2Z”, etc. use the ORDER BY. Let us first create a table −mysql> create table DemoTable -> ( -> StudentId varchar(100) -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2X'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('100Y'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('100X'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2Z'); Query OK, 1 row affected (0.14 sec) mysql> ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
3K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> NumberOfItems int, -> Amount int -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(4, 902); Query OK, 1 row affected (0.45 sec) mysql> insert into DemoTable values(5, 1000); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(3, 80); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+---------------+--------+ | NumberOfItems | Amount | +---------------+--------+ | ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
452 Views
Let us first create a table −mysql> create table DemoTable1 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(Name) values('Chris'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1(Name) values('Robert'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;Output+----+--------+ | Id | Name | +----+--------+ | 1 | Chris | | 2 | Robert | +----+--------+ 2 ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
330 Views
For this, you can use aggregate function COUNT(*). Let us first create a table in let’s say database “web” −mysql> create table DemoTable1 -> ( -> Value int -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1 values(20); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;OutputThis will produce the following output −+-------+ | Value | +-------+ | 10 | | ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
504 Views
Following is the syntax −update yourTableName set yourColumnName1= yourValue where yourColumnName2=yourValue order by yourColumnName2 DESC LIMIT 1;Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 'John'); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable values(2, 'Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(2, 'Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
106 Views
Following is the syntax −show create view yourViewName;Let us first create a table −mysql> create table DemoTable -> ( -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Robert'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;OutputThis will produce the following output −+-------------+ | StudentName | +-------------+ | ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
197 Views
For this, you can use INSERT(). Let us first create a table −mysql> create table DemoTable -> ( -> ZipCode varchar(200) -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('9030'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('3902'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('9083'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('9089'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
379 Views
Use LENGTH() for this. Let us first create a table −mysql> create table DemoTable -> ( -> Value text -> ); Query OK, 0 rows affected (0.74 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('10, 20, 10, 30, 10, 40, 50, 40'); Query OK, 1 row affected (0.24 sec)Display all records from the table using select statement −mysql> select *from DemoTable;OutputThis will produce the following output −+-------------------------+ | Value | +-------------------------+ | 10, 20, 10, 30, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
178 Views
Use ALTER command for this. Let us first create a table −mysql> create table DemoTable -> ( -> StudentName varchar(100) -> ); Query OK, 0 rows affected (0.46 sec)Here is the query to insert auto_increment −mysql> alter table DemoTable ADD COLUMN StudentId int NOT NULL; Query OK, 0 rows affected (0.50 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table DemoTable ADD PRIMARY KEY(StudentId); Query OK, 0 rows affected (1.23 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table DemoTable CHANGE StudentId StudentId int NOT NULL AUTO_INCREMENT; Query OK, 0 rows affected (2.20 sec) Records: 0 ... Read More