Find Date Record After a Particular Date from Varchar Column in MySQL

AmitDiwan
Updated on 08-Nov-2019 10:55:46

207 Views

Let us first create a table. Here, we have set date as VARCHAR −mysql> create table DemoTable1364     -> (     -> ShippingDate varchar(100)     -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1364 values('01-09-2019 12:34:55'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1364 values('01-07-2018 17:10:00'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable1364 values('24-09-2019 10:31:22'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1364 values('20-09-2018 13:00:00'); Query OK, 1 row affected (0.13 sec)Display all records from ... Read More

Math Ceiling Method in C#

AmitDiwan
Updated on 08-Nov-2019 10:54:17

4K+ Views

The Math.Ceiling() method in C# is used to return the smallest integral value greater than or equal to the specified number.SyntaxFollowing is the syntax −public static decimal Ceiling (decimal val); public static double Ceiling(double val)For the first syntax above, the value Val is the decimal number, whereas Val in the second syntax is the double number.ExampleLet us now see an example to implement Math.Ceiling() method −using System; public class Demo {    public static void Main(){       decimal val1 = 9.99M;       decimal val2 = -5.10M;       Console.WriteLine("Result = " + Math.Ceiling(val1));     ... Read More

Using MySQL IN for Column Values with Underscore

AmitDiwan
Updated on 08-Nov-2019 10:53:26

201 Views

Let us first create a table −mysql> create table DemoTable1363     -> (     -> StudentId varchar(20)     -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1363 values('901'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1363 values('702'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1363 values('901_John_Doe'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1363 values('1001_Carol_Taylor'); Query OK, 1 row affected (0.26 sec)Display all records from the table using select statement −mysql> select * from DemoTable1363;This will ... Read More

Byte GetHashCode Method in C#

AmitDiwan
Updated on 08-Nov-2019 10:52:32

128 Views

The Byte.GetHashCode() method in C# is used to return the hash code for the current instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the Byte.GetHashCode() method −using System; public class Demo {    public static void Main(){       long val = 5654665;       byte[] arr = BitConverter.GetBytes(val);       for (int i = 0; i < arr.Length; i++) {          int res = arr[i].GetHashCode();          Console.WriteLine("Hashcode = "+res);       }    } }OutputThis will produce the following output −Hashcode = 137 Hashcode = 72 Hashcode = 86 Hashcode = 0 Hashcode = 0 Hashcode = 0 Hashcode = 0 Hashcode = 0

MySQL Permissions to View All Databases

AmitDiwan
Updated on 08-Nov-2019 10:51:40

274 Views

For this, the syntax is as follows −revoke show databases on *.* from 'yourUserName'@'yourHostName';Let us display all usernames along with host name −mysql> select user, host from MySQL.user;This will produce the following output −+------------------+-----------+ | user             | host      | +------------------+-----------+ | Bob              | %         | | Charlie          | %         | | Robert           | %         | | User2            | %   ... Read More

Byte Equals Object Method in C#

AmitDiwan
Updated on 08-Nov-2019 10:50:07

133 Views

The Byte.Equals(Object) method in C# returns a value indicating whether this instance is equal to a specified object.SyntaxFollowing is the syntax −public override bool Equals (object ob);Above, ob is an object to compare with this instance or null.ExampleLet us now see an example to implement the Byte.Equals(Object) method −using System; public class Demo {    public static void Main(){       byte b1;       b1 = 5;       object b2 = 5/10;       if (b1.Equals(b2))          Console.Write("b1 = b2");       else          Console.Write("b1 is not equal to b2");    } }OutputThis will produce the following output −b1 is not equal to b2

Create Variables in MySQL Stored Procedure with DECLARE Keyword

AmitDiwan
Updated on 08-Nov-2019 10:49:23

724 Views

Use MySQL DECLARE for variables in stored procedure −DECLARE anyVariableName int DEFAULT anyValue;Let us implement the above syntax in order to create variables in stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE variable_Demo()     -> BEGIN     -> DECLARE lastInsertedId int DEFAULT -1;     -> select lastInsertedId;     -> set @providedLastId=10001;     -> select @providedLastId;     -> END     -> // Query OK, 0 rows affected (0.32 sec) mysql> DELIMITER ;Now you can call the above stored procedure using CALL command −mysql> call variable_Demo();This will produce the following output −+----------------+ | lastInsertedId | ... Read More

Boolean CompareTo Object Method in C#

AmitDiwan
Updated on 08-Nov-2019 10:48:27

136 Views

The Boolean.CompareTo(Object) method in C# compares this instance to a specified object and returns an integer that indicates their relationship to one another.SyntaxFollowing is the syntax −public int CompareTo (object ob);Above, the parameter ob is an object to compare to this instance, or null.ExampleLet us now see an example to implement the Boolean.CompareTo(Object) method −using System; public class Demo {    public static void Main(){       bool b1 = false;       object b2 = false;       int res = b1.CompareTo(b2);       if (res > 0)          Console.Write("b1 > b2"); ... Read More

Treat MySQL Column Field as Null If It Is Blank

AmitDiwan
Updated on 08-Nov-2019 10:47:17

249 Views

Let us first create a table −mysql> create table DemoTable1362     -> (     -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,     -> ClientName varchar(40)     -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1362(ClientName) values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1362(ClientName) values(' '); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1362(ClientName) values('Bob'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1362(ClientName) values(' '); Query OK, 1 row affected (0.12 sec) mysql> insert ... Read More

Boolean CompareTo Method in C#

AmitDiwan
Updated on 08-Nov-2019 10:46:15

636 Views

The Boolean.CompareTo(Boolean) method in C# is used to compare this instance to a specified Boolean object and returns an integer that indicates their relationship to one another.SyntaxFollowing is the syntax −public int CompareTo (bool val);Above, Val is a Boolean object to compare to the current instance.ExampleLet us now see an example to implement the Boolean.CompareTo(Boolean) method −using System; public class Demo {    public static void Main(){       bool b1, b2;       b1 = false;       b2 = false;       int res = b2.CompareTo(b1);       if (res > 0)   ... Read More

Advertisements