- 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)
105 Views
For this, you can use case statement. Let us first create a table −mysql> create table DemoTable1794 ( Amount int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1794 values(100); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1794 values(80); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1794 values(320); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1794;This will produce the following output −+--------+ | Amount | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
To avoid any issues while running a query, use IFNULL(). Let us first create a table −mysql> create table DemoTable1793 ( StudentFirstName varchar(20), StudentLastName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1793 values('John', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1793 values('Carol', NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1793 values(NULL, 'Brown'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
63 Views
To select not-null records, use IS NOT NULL property. Let us first create a table −mysql> create table DemoTable1792 ( Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1792 values('John Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1792 values(NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1792 values('David Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1792 values(NULL); Query OK, 1 row affected (0.00 sec)Display all records from the table using ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
69 Views
The following syntax will fetch all the values from the column −select * from yourTableName where yourColumnName=0;Let us first create a table −mysql> create table DemoTable1791 ( FirstName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1791 values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1791 values('John'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1791 values('Carol'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1791;This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
597 Views
For this, you can use aggregate function sum() along with parameter value for specific column. Let us first create a table −mysql> create table DemoTable1790 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20), Score int ); Query OK, 0 rows affected (0.94 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1790(Name, Score) values('Chris', 45); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable1790(Name, Score) values('David', 55); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1790(Name, Score) values('David', 98); Query OK, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
217 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Value longtext -> ); Query OK, 0 rows affected (0.94 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('778437437447488487476464644433334'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('9998888485775775757577578585'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('8888874757757757757757575675656'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('988757757574646'); Query OK, 1 row affected (0.09 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
476 Views
Use INSERT INTO statement in the Java-MySQL connection code to insert a column.Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.54 sec)Here is the Java code to insert only a single column into a MySQL table.Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class InsertOneColumnDemo { public static void main(String[] args) { Connection con = null; PreparedStatement ps = null; try { con = DriverManager.getConnection("jdbc:mysql://localhost:3306/web?" + "useSSL=false", "root", "123456"); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (1.37 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(101, 'Chris'); Query OK, 1 row affected (0.54 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(103, 'Mike'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following output −+------+-------+ | Id ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
143 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Code varchar(20) -> ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('J23'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('C13'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('A61'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('D56'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
178 Views
To add a new NOT NULL column to an already created table, use ALTER command. Let us first create a table −mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.60 sec)Following is the query to add a new NOT NULL column to an existing table −mysql> alter table DemoTable add column StudentAge int NOT NULL; Query OK, 0 rows affected (0.52 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName, ... Read More