AmitDiwan has Published 10740 Articles

To return value of a number raised to the power of another number, we should use ^ operator in MySQL?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:53:54

116 Views

No, ^ is the Bitwise XOR operator in MySQL. For this, use POW() or POWER() from MySQL. Let us first create a table &minuns;mysql> create table DemoTable (    BaseValue int,    PowerValue float ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command ... Read More

How to display records having sum between a specific range using GROUP BY, HAVING and ORDER BY in a single MySQL query?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:51:33

442 Views

Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    CustomerName varchar(20),    ProductPrice int ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerName, ProductPrice) values('Chris', 600); Query OK, ... Read More

Display duplicate record as a distinct value with corresponding values as distinct comma separated list in MySQL?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:47:06

624 Views

For this, you can use GROUP_CONCAT(). You also need to use DISTINCT to fetch distinct records. Let us first create a table −mysql> create table DemoTable(    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(40),    Score int ); Query OK, 0 rows affected (0.53 sec)Insert some records ... Read More

How to sum selected column values based on specific month records in MySQL?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:44:57

374 Views

Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    PurchaseDate date,    SalePrice int ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2018-01-10', 450); Query OK, ... Read More

Does UPDATE overwrite values if they are identical in MySQL

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:42:42

493 Views

No, MySQL UPDATE won’t overwrite values if they are identical. Let us first create a table −mysql> create table DemoTable (    StudentId int,    StudentMathMarks int,    StudentMySQLMarks int ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable ... Read More

Count from two tables and give combined count of string in MySQL?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:38:31

238 Views

To count, use the MySQL COUNT(*). However, with UNION ALL you would be able to get a combined count of string. Let us first create a table −mysql> create table DemoTable1 (    Name varchar(20) ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert ... Read More

MySQL Stored Procedure calling with INT and VARCHAR values

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:36:19

1K+ Views

To call a stored procedure, you can use CALL command. Following is the syntax −CALL yourStoredProcedureName(parameter if any);Let us first create a sample procedure. Following is the query to create a stored procedure. Here, we have set two values, one is an INT and another VARCHAR −mysql> DELIMITER // mysql> ... Read More

How to execute multiple select queries in MySQL ?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:33:06

4K+ Views

To execute multiple select queries in MySQL, use the concept of DELIMITER. Let us first create a table −mysql> create table DemoTable1 (    Title text )ENGINE=MyISAM; Query OK, 0 rows affected (0.30 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values('The database MySQL is ... Read More

Why the following is showing an error in MySQL: INSERT INTO yourTableName VALUE(yourValue1,yourValue2,.......N);?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:28:01

197 Views

The error is in the syntax of VALUE().Use VALUES() instead of VALUE(). The correct syntax of the insert query is as follows −INSERT INTO yourTableName VALUES(yourValue1, yourValue2, .......N);Let us first create a table −mysql> create table DemoTable (    StudentId int,    StudentName varchar(40),    StudentAge int ); Query OK, ... Read More

How to create a new table from the first table using MySQL LIKE?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:25:21

133 Views

Let us first create a table −mysql> create table DemoTable1 (    EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    EmployeeName varchar(50) ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(EmployeeName) values('Tom'); Query OK, 1 row affected (0.19 sec) ... Read More

Advertisements