AmitDiwan has Published 10744 Articles

How to change MySQL ending statement?

AmitDiwan

AmitDiwan

Updated on 26-Feb-2020 05:36:06

195 Views

To change the MySQL ending statement, you can use DELIMITER −DELIMITER anySymbolAbove, anySymbol is the symbol you can set. The default is DELIMITER ;Let us first create a table −mysql> DELIMITER // mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20)    -> )// ... Read More

Query to find Nth maximum value in MySQL

AmitDiwan

AmitDiwan

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

164 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

528 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

130 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

754 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

215 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

604 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

542 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

283 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

215 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

Advertisements