AmitDiwan has Published 11365 Articles

The MySQL EXPLAIN keyword executes the query or just explains the query?

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 09:31:40

68 Views

The EXPLAIN keyword tells how MySQL executes the query. Let us first create a table −mysql> create table DemoTable1375    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> FirstName varchar(20),    -> INDEX FIRST_INDEX(FirstName)    -> ); Query OK, 0 rows affected (0.73 sec)Insert some ... Read More

How to use count with CASE condition in a MySQL query?

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 09:27:50

3K+ Views

Use CASE WHEN for this in MySQL and set CASE condition inside the COUNT() method to count. Let us first create a table −mysql> create table DemoTable1374    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20),    -> Score int    -> ); ... Read More

Update a MySQL column with JSON format?

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 09:25:42

867 Views

To display records like JSON format, use MySQL concat(). Let us first create a table −mysql> create table DemoTable1373    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentDetails text    -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table ... Read More

Subtracting a number from a single MySQL column value?

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 09:23:28

654 Views

For this, just update the table and subtract. Let us first create a table −mysql> create table DemoTable1372    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1372 values(500); Query OK, ... Read More

Get values from all rows and display it a single row separated by comma with MySQL

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 09:21:18

1K+ Views

For this, use GROUP_CONCAT(). Do not use GROUP BY clause, since GROUP_CONTACT() is a better and quick solution.Let us first create a table −mysql> create table DemoTable1371    -> (    -> Id int,    -> CountryName varchar(40)    -> ); Query OK, 0 rows affected (0.89 sec)Insert some records ... Read More

Get the sum only from specific cells in MySQL?

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 09:19:59

92 Views

For only specific cells, set a condition with WHERE and use aggregate function SUM() to add. Let us first create a table −mysql> create table DemoTable1370    -> (    -> StudentName varchar(20),    -> Marks int    -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in ... Read More

DateTimeOffset.AddMonths() Method in C#

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 07:48:50

183 Views

The DateTimeOffset.AddMonths() method in C# is used to add a specified number of months to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddMonths (int val);Above, Val is the number of months to be added. For subtracting months, set a negative value.ExampleLet us now see an example to ... Read More

DateTimeOffset.AddMinutes() Method in C#

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 07:47:39

280 Views

The DateTimeOffset.AddMinutes() method in C# is used to adds a specified number of whole and fractional minutes to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddMinutes (double val);Above, Val is the number of minutes to be added. To subtract, set a negative value for minutes.ExampleLet us now ... Read More

Byte.Equals(Byte) Method in C#

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 07:45:44

264 Views

The Byte.Equals(Byte) method in C# returns a value indicating whether this instance and a specified Byte object represent the same value.SyntaxFollowing is the syntax −public bool Equals (byte ob);Above, ob is an object to compare to this instance.ExampleLet us now see an example to implement the Byte.Equals(Byte) method −using System; ... Read More

Byte.CompareTo(Object) Method in C#

AmitDiwan

AmitDiwan

Updated on 11-Nov-2019 07:44:41

43 Views

The Byte.CompareTo(Object) method in C# is used to compare this instance to a specified object and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (object val);Above, Val is an object to compare or null.The return value is less than zero if the current instance is ... Read More

Advertisements