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 in the table using insert command −mysql> insert into DemoTable(Name, Score) values('Chris', 56); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Name, Score) values('Robert', 78); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name, Score) values('Chris', 56); Query OK, 1 row affected (0.42 sec) mysql> insert ... Read More
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, 1 row affected (0.12 sec) mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2019-12-25', 1000); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2016-12-02', 5560); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2015-02-20', 4550); Query OK, 1 row affected (0.18 sec) mysql> insert into ... Read More
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 values(1, 56, 78); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(2, 88, 99); Query OK, 1 row affected (0.15 sec) mysql> inse rt into DemoTable values(3, 34, 98); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from ... Read More
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 command. We are inserting string values in the first table −mysql> insert into DemoTable1 values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1 values('Robert'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1 values('Mike'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1 ... Read More
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> CREATE PROCEDURE CALL_PROC(Id int, Name varchar(40)) BEGIN SELECT CONCAT('You have entered the Id which is=', Id); SELECT CONCAT('You have entered the Name which is=', Name); END // Query OK, 0 rows affected (0.21 sec) mysql> DELIMITER ;Following is the query to call a stored procedure in ... Read More
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 less popular than MongoDB') ; Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1 values('Java language uses MySQL database'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable1 values('Node.js uses the MongoDB') ; Query OK, 1 row affected (0.05 sec)Display all records from the table using ... Read More
For learning about the angle between two planes in 3D, we need to learn about planes and angles.Plane is a two-dimensional surface that extends to infinity.Angle is the space in degrees between two lines and surfaces which intersect at a point.So, in this problem we need to find the angle between two 3D planes. For this we have two planes that intersect each other and we need to find the angle at which the are intersecting each other.To calculate the angle between two 3D planes, we need to calculate the angle between the normal's of these planes.Here, we have two ... Read More
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, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> INSERT INTO DemoTable VALUES(1001, 'Tom', 20); Query OK, 1 row affected (0.11 sec) mysql> INSERT INTO DemoTable VALUES(1002, 'Mike', 21); Query OK, 1 row affected (0.13 sec) mysql> INSERT INTO DemoTable VALUES(1003, 'Sam', 19); Query OK, ... Read More
BFS (Breadth First Search) − It is a tree traversal algorithm that is also known as Level Order Tree Traversal. In this traversal we will traverse the tree row by row i.e. 1st row, then 2nd row, and so on.DFS (Depth First Search ) − It is a tree traversal algorithm that traverses the structure to its deepest node. There are three most used methods that are used to traverse the tree using DFS. it goes into depth of each node as the root node and then goes to the next one.Solved for a TreeLet’s find the traversal of a ... Read More
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) mysql> insert into DemoTable1(EmployeeName) values('Mike'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1(EmployeeName) values('Emma'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1(EmployeeName) values('Sam'); Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement::mysql> select *from DemoTable1;This will produce the ... Read More