- 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
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
876 Views
Use ORDER BY and set DESC to order by desc. However, to get all the values except a single value, use the not equal operator.Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Sam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
224 Views
Use INSERT() function from MySQL. It has the following parameters −ParameterDescriptionstrString to be modifiedpositionPosition where to insert str2numberNumber of characters to replacestr2String to insert into strLet us first create a table −mysql> create table DemoTable -> ( -> Code varchar(100) -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('958575/98') ; Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('765432/99'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('983456/91'); Query OK, 1 row affected (0.15 sec)Display all ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
3K+ Views
Use ALTER for this with ADD. Following is the syntax −alter table yourTableName add yourColumnName DATETIME DEFAULT NOW(), add index(yourColumnName);Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(100), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.69 sec)Let us check the description of the table −mysql> desc DemoTable;OutputThis will produce the following output −+-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | Id | int(11) ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
60 Views
For this, you can use the LIKE clause. Let us first create a table −mysql> create table DemoTable -> ( -> ClientName varchar(100) -> ); Query OK, 0 rows affected (0.85 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John Smith'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Smith John'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Jone Deo'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Deo Jone'); Query OK, 1 row affected (0.14 sec) mysql> ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
156 Views
For this, use ALTER command. Let us first create a table. The default engine is set as“MYISAM” −mysql> create table DemoTable -> ( -> ClientId int NOT NULL AUTO_INCREMENT, -> ClientName varchar(100), -> ClientAge int, -> ClientCountryName varchar(100), -> isMarried boolean, -> PRIMARY KEY(ClientId) -> )ENGINE=MyISAM; Query OK, 0 rows affected (0.67 sec)Following is the query to convert table from MyISAM to INNODB −mysql> alter table DemoTable ENGINE=InnoDB; Query OK, 0 rows affected (1.97 sec) Records: 0 Duplicates: 0 Warnings: 0Let us now check the status of table −mysql> show create table DemoTable;OutputThis will produce the following output displaying the ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
11K+ Views
To select top 10 records, use LIMIT in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> PageNumber text -> ); Query OK, 0 rows affected (2.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Page-1'); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable values('Page-2'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Page-3'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values('Page-4'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Page-5'); Query OK, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
570 Views
For this, use COLUMN_NAME and set LIKE with that specific column name. Let us find a specific column in an unknown table in a database −mysql> SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT -> FROM INFORMATION_SCHEMA.COLUMNS -> WHERE column_name LIKE '%StudentName%' -> AND table_schema = 'web';OutputThis will produce the following output −+-------------------+-------------+-----------+-------------+----------------+ | TABLE_NAME | COLUMN_NAME | DATA_TYPE | IS_NULLABLE |COLUMN_DEFAULT | +-------------------+-------------+-----------+-------------+----------------+ | demotable215 | StudentName | varchar | YES | NULL | | demotable221 | StudentName | varchar ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
146 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name text -> ); Query OK, 0 rows affected (1.31 sec)Insert some records in the table using insert command. Here, we have inserted a name with a specific word “name”, which we need to ignore −mysql> insert into DemoTable values('John 7'); Query OK, 1 row affected (0.65 sec) mysql> insert into DemoTable values('John 6'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable values('John 9'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable values('name John 3'); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
204 Views
Let us first create a table −mysql> create table DemoTable -> ( -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (1.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 'Smith'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 'Miller'); Query OK, 1 row affected (0.24 sec)Display all records from the table using ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
109 Views
Use the COLUMN_NAME to find which table in a database contains a specific column. Let us first create a table −mysql> create table DemoTable -> ( -> CustomerId int, -> CustomerName varchar(20), -> CustomerCountryName varchar(100) -> ); Query OK, 0 rows affected (1.05 sec)Following is the query to find in which tables a specific column “'CustomerCountryName'” is present −mysql> select *from information_schema.columns WHERE COLUMN_NAME = 'CustomerCountryName';OutputThis will produce the following output −+---------------+--------------+--------------+---------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+--------------+------------+-------+---------------------------------+----------------+-----------------------+-------+ | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME |ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE |CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH |NUMERIC_PRECISION ... Read More