AmitDiwan has Published 10740 Articles

Query to find Nth maximum value in MySQL

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:34:15

187 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.26 sec) mysql> insert into ... Read More

How to batch update MySQL table?

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:27:26

582 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> BreakfastTime time    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('7:30:45'); Query OK, 1 row affected (0.19 sec) mysql> insert into ... Read More

Implement SELECT LIKE and CHAR_LENGTH() in a single MySQL query

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:26:32

148 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris Brown'); Query OK, 1 row affected (0.19 sec) mysql> insert ... Read More

Update all the fields in a table with null or non-null values with MySQL

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:25:47

790 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, NULL); Query OK, 1 row affected ... Read More

Is it okay to store double and date in VARCHAR with MySQL?

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:24:46

243 Views

Yes, you can store double and date in VARCHAR. Let us first create a table −mysql> create table DemoTable    -> (    -> Amount varchar(20),    -> JoiningDate varchar(20)    -> ); Query OK, 0 rows affected (0.96 sec)Insert some records in the table using insert command. We are ... Read More

SUM corresponding duplicate records in MySQL

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:23:52

642 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> StudentName varchar(20),    -> StudentMarks int    -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 50); Query OK, 1 row affected ... Read More

MySQL query to find duplicate tuples and display the count?

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:22:43

594 Views

To find duplicate tuples, use GROUP BY HAVING clause. Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.80 sec)Insert some records in the table using insert command −mysql> insert ... Read More

Adding a new NOT NULL column to an existing table with records

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:20:44

332 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 ... Read More

Sort character values from a column mixed with character and numbers in MySQL?

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:19:51

248 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 ... Read More

How to fetch only a single result from a table in Java-MySQL?

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:04:00

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 ... Read More

Advertisements