This is a C++ program to compute Combinations using Recurrence Relation for nCr.AlgorithmsBegin function CalCombination(): Arguments: n, r. Body of the function: Calculate combination by using the formula: n! / (r! * (n-r)!. EndExample#include<iostream> using namespace std; ... Read More
Both pow() and power() are synonyms in MySQL. Following is the syntax −select pow(yourValue1, yourValue2); OR select power(yourValue1, yourValue2);Let us implement both the above syntaxes.Using POW()mysql> select POW(4, 3);This will produce the following output −+----------+ | POW(4, 3) | +----------+ | 64 | +----------+ ... Read More
This is a C++ program to generate a sequence of N characters for a given specific case.AlgorithmsBegin function GenerateSequence() generate a Sequence of N Characters for a Given Specific Case: Use rand() for generating random indexes. Store the first character directly into the ... Read More
Let us first create a table wherein we have a Primary Key CustomerId −mysql> create table DemoTable ( CustomerId int NOT NULL AUTO_INCREMENT, CustomerName varchar(20), CustomerAge int, CustomerCountryName varchar(100), PRIMARY KEY(CustomerId) ); Query OK, 0 rows affected (0.94 sec)Following is the query to ... Read More
To convert MM/DD/YY to UNIX timestamp, you can use the below syntax −select UNIX_TIMESTAMP(str_to_date(yourColumnName, '%m/%d/%Y')) from yourTableName;Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, dateConvertToUnix varchar(100) ); Query OK, 0 rows affected (0.58 sec)Insert some records ... Read More
You can use substring() for fields in MySQL to get part of string. Following is the syntax −select substring(yourColumnName, yourStartingIndex, yourEndingIndex) from yourTableName;Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Title longtext ); Query OK, 0 ... Read More
You cannot use ‘from’ as column name directly because ‘from’ is a reserved word in MySQL.If you want to still use it, then you need to use the backtick symbol.Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Read More
First, you need to know how many columns are present in a table. Following is the syntax to know the column names −show columns from yourTableName;Following is the syntax to concatenate all columns −select concat(yourColumnName1, yourColumnName2, yourColumnName3, ........N) from yourTableName;Let us first create a table −mysql> create table DemoTable ... Read More
You can use aggregate function MAX() and MIN() for this.Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number1 int, Number2 int ); Query OK, 0 rows affected (0.89 sec)Insert records in the table using insert ... Read More
To modify an existing column’s data type, you can use MODIFY. Let us first create a table −mysql> create table DemoTable ( ClientId varchar(100), ClientName varchar(100), ClientAge int, ClientProjectDeadline timestamp, ClientCountryName varchar(100), isMarried boolean, ClientNumber bigint ); Query OK, 0 rows ... Read More
You can use UPDATE with DATE_ADD() to update all dates. Let us first create a table −mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientProjectDueDate date ); Query OK, 0 rows affected (1.19 sec)Insert records in the table using insert command −mysql> ... Read More
You can use COUNT(*) along with GROUP BY for this. Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentAge int ); Query OK, 0 rows affected (0.59 sec)Insert records in the table using insert command −mysql> ... Read More
You can use a CASE statement for this. Let us first create a table −mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.71 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(490); Query OK, 1 row affected (0.35 ... Read More
Let us first create a table −mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(30) ); Query OK, 0 rows affected (0.74 sec)Insert records in the table using insert command −mysql> insert into DemoTable(ClientName) values('John'); Query OK, 1 row affected (0.20 ... Read More
Let us first create a table and index −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(20), StudentAge int, StudentCountryName varchar(100), INDEX first_Name_index(StudentFirstName) ); Query OK, 0 rows affected (1.01 sec)Check the description of the table −mysql> desc ... Read More
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more