
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 4381 Articles for MySQL

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

121 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

115 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

702 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

299 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

581 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

3K+ 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

212 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

282 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

293 Views
Let us first create a table −mysql> create table DemoTable -> ( -> DueDate date -> ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-01-11'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('2019-04-19'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+------------+ | DueDate | +------------+ | 2019-01-11 | | 2019-04-19 | +------------+ 2 rows in set (0.00 sec)Following is the query to display ... Read More