AmitDiwan has Published 8358 Articles

Count values based on conditions and display the result in different columns with MySQL?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 07:15:06

188 Views

Let us first create a table −mysql> create table DemoTable1485     -> (     -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,     -> StudentName varchar(20),     -> StudentSubject varchar(20)     -> ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table ... Read More

Using MySQL where clause and ordering by avg() to find the average of duplicate individual elements

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 07:12:03

265 Views

For this, use having clause instead of where. Let us first create a table −mysql> create table DemoTable1338    -> (    -> Name varchar(10),    -> Score int    -> ); Query OK, 0 rows affected (1.54 sec)Insert some records in the table using insert command. Here, we have ... Read More

Fetch maximum value from a column with values as string numbers like Value440, Value345, etc. in SQL

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 07:08:47

136 Views

For this, you can use MAX() along with substring(). Let us first create a table −mysql> create table DemoTable1337    -> (    -> Value varchar(50)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1337 values('Value400'); Query ... Read More

Math.Truncate() Method in C#

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 07:05:05

667 Views

The Math.Truncate() method in C# is used to compute an integral part of a number, which is Double or Decimal.Syntaxpublic static decimal Truncate(decimal val1) public static double Truncate(double val2)Above, there are two syntaxes. The value val1 is the decimal number to truncate, whereas val2 is the double number to truncate.ExampleLet ... Read More

Select different fields in MySQL even if a field is set to null?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 07:01:32

198 Views

For this, you can use COALESCE(). Let us first create a table −mysql> create table DemoTable1336    -> (    -> FirstName varchar(20)    -> ,    -> SecondName varchar(20)    -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert ... Read More

Math.Tanh() Method in C#

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 07:01:26

143 Views

The Math.Tanh() method in C# is used to return the hyperbolic tangent of the specified angle.Syntaxpublic static double Tanh (double val);Above, Val is the angle.ExampleLet us now see an example to implement Math.Tanh() method −using System; public class Demo {    public static void Main(){       double val1 ... Read More

Select entries with timestamp after X time in MySQL

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:59:01

480 Views

Let us first create a table −mysql> create table DemoTable1335    -> (    -> ArrivalTime datetime    -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command. We have inserted date time records here −mysql> insert into DemoTable1335 values('2019-09-19 22:54:00'); Query OK, ... Read More

CharEnumerator.Reset() Method in C#

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:58:50

138 Views

The CharEnumerator.Reset() method in C# initializes the index to a position logically before the first character of the enumerated string.Syntaxpublic void Reset ();ExampleLet us now see an example to implement the CharEnumerator.Reset() method −using System; public class Demo {    public static void Main(){       string strNum = ... Read More

Insert values in two tables with a single stored procedure call in MySQL

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:56:13

2K+ Views

Following is the syntax to insert values in two tables with a stored procedure −DELIMITER // CREATE PROCEDURE yourProcedureName(anyVariableName int)    BEGIN    insert into yourTableName1(yourColumnName1) values(yourVariableName);    insert into yourTableName2(yourColumnName2) values(yourVariableName);    END //Let us first create a table −mysql> create table DemoTable1    -> (    -> StudentScore ... Read More

MySQL row declarations for ZF?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:53:33

303 Views

The ZF stands for ZEROFILL i.e. row declarations for zero fill Let us first create a table. Here, we have set the int field size to be 10 −mysql> create table DemoTable1332    -> (    -> Number int(10) ZEROFILL NOT NULL DEFAULT 0    -> ); Query OK, 0 ... Read More

Advertisements