Working with WHERE IN in a MySQL Stored Procedure

AmitDiwan
Updated on 28-Feb-2020 07:36:44

1K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(101, 'Bob'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following output −+------+-------+ | Id   ... Read More

Sum Cells in a Column Based on Condition in Another Column with MySQL

AmitDiwan
Updated on 28-Feb-2020 07:31:19

1K+ Views

For this, you can use the aggregate function SUM() along with the GROUP BY clause. Let us first create a table −mysql> create table DemoTable    -> (    -> EmployeeName varchar(20),    -> JoiningDate date,    -> Salary int    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('David', '2019-11-02', 400); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable values('Robert', '2018-11-25', 100); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable values('Bob', '2019-12-14', 600); Query OK, 1 row affected (0.25 sec) ... Read More

Add Records from Corresponding Duplicate Values in Another Column with MySQL

AmitDiwan
Updated on 28-Feb-2020 07:30:06

245 Views

For this, you can use the aggregate function SUM() along with the GROUP BY clause. Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(20),    -> Value int    -> ); Query OK, 0 rows affected (2.08 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 50); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 90); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Chris', 60); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Bob', 100); Query ... Read More

Find Specific Records from a Column with Comma-Separated Values in MySQL

AmitDiwan
Updated on 28-Feb-2020 07:28:16

875 Views

For this, you can use FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable    -> (    -> ListOfValue varchar(20)    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('78, 89, 65'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('88, 96, 97'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('95, 96, 99, 100'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('78, 45, 67, 98'); Query OK, 1 row affected (0.10 sec)Display all ... Read More

Ratio Greater Equal Function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 07:02:51

94 Views

Given is the task to show the working of ratio_greater_equal () function in C++.The given function Ratio_greater_equal checks if the value of ratio1 is greater or equal than ratio2. It returns a Boolean constant “value” which returns true if ratio1 is greater or equal than ratio2 else returns false.SyntaxTemplate ratio_greater_equalParametersThis function accepts two template parameters one is ratio1 and another one is ratio2 which are to be compared.Explanation of this functionIn this function, if the value of ratio1 is greater than or equal to the value of ratio2 then this function will return the Boolean value which is true ... Read More

Ratio Greater Function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 06:59:03

46 Views

Given is the task to show the working of ratio_greater () function in c++.The given function Ratio_greater checks if the value of ratio1 is greater than ratio2. It returns a Boolean constant “value” which returns true if ratio1 is greater than ratio2 else returns false.SyntaxTemplate ratio_greaterParametersThis function accepts two template parameters one is ratio1 and another one is ratio2 which are to be compared.Explanation of this functionIn this function, if the value of ratio1 is greater than the value of ratio2 then this function will return the Boolean value which is true i.e. integer digit 1 otherwise it will ... Read More

Ratio Less Function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 06:52:44

91 Views

Given is the task to show the working of ratio_less () function in C++.The function ratio_less() checks if the value of ratio1 is less than ratio2. It returns a Boolean constant “value” which returns true if ratio1 is less than ratio2 else returns false.ExampleInput: 1/3 and 3/9 Output: 1/3 is less than 3/9. Input: 1/4 and 1/8 Output: 1/4 is not less than 1/8.SyntaxTemplate ratio_lessParametersThis function accepts two template parameters one is ratio1 and another one is ratio2 which are to be compared.ExplanationIn this function, if the value of ratio1 is less than the value of ratio2 then this ... Read More

Reverse Forward List in C++ STL

Sunidhi Bansal
Updated on 28-Feb-2020 06:49:22

305 Views

Given is the task to show the working of forward_list::reverse( ) function in C++ STL.What is a Forward List?Forward list can be understood as a singly linked list where the tracking can be done only in forward direction but not in a backward direction whereas in the list we can track the elements in both the direction i.e. the element holds the two links one is for forward element and another one is for backward element. Forward lists are therefore fast because they have to hold only one link which will be of a forward element. Forward elements can be ... Read More

Forward List Swap in C++ STL

Sunidhi Bansal
Updated on 28-Feb-2020 06:47:19

185 Views

Given is the task to show the working of forward_list::swap( ) function in C++.What is a Forward List?Forward list is a sequence container that allow constant time insert and erase operations anywhere within the sequence. Forward list are implement as a singly-linked lists. The ordering is kept by the association to each element of a link to the next element in the sequence.What is forward_list::swap()?forward_list::swap( ) is a function in c++ standard library function which is used to swap the contents of one list to another list of same size and same data type.Syntaxforward_list1.swap(forward_list2)Orswap(forward_list first, forward_list second)ExampleOutput – First list ... Read More

Forward List Unique in C++ STL

Sunidhi Bansal
Updated on 28-Feb-2020 06:42:16

234 Views

Given is the task to show the working of forward_list::unique( ) function in C++.Forward list are sequence containers that allow constant time insert and erase operations anywhere within the sequence. Forward list are implement as a singly-linked lists. The ordering is kept by the association to each element of a link to the next element in the sequence.forward_list::unique( ) is a function in c++ standard library function which is used to remove the all duplicate elements from forward list. Notice that an element is only removed from the forward_list container if it compare equal to the element immediately it. Thus, ... Read More

Advertisements