Treat MySQL Column Field as Null If It Is Blank

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

233 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

627 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

Find All Tables Containing Two Specific Columns in MySQL

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

693 Views

To find two specific column names, use information_schema.columns Here, I am using Id in place of columnA and Name in place of columnB −mysql> select table_name as TableNameFromWebDatabase    -> from information_schema.columns    -> where column_name IN ('Id', 'Name')    -> group by table_name    -> having count(*) = 3;This will produce the following output. Following are the tables with columns Id and Name −+--------------------------+ | TableNameFromWebDatabase | +--------------------------+ | student                  | | distinctdemo             | | secondtable              | | groupconcatenatedemo ... Read More

BitConverter ToBoolean Method in C#

AmitDiwan
Updated on 08-Nov-2019 10:43:35

139 Views

The BitConverter.ToBoolean() method in C# returns a Boolean value converted from the byte at a specified position in a byte array.SyntaxFollowing is the syntax −public static bool ToBoolean (byte[] arr, int startIndex);Above, arr is a byte array, whereas startIndex is the index of the byte within a value.ExampleLet us now see an example to implement the BitConverter.ToBoolean() method −using System; public class Demo {    public static void Main(){       byte[] arr = { 50, 100 };       Console.WriteLine("Array values...");       for (int i = 0; i < arr.Length; i++) {       ... Read More

DateTime IsLeapYear Method in C#

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

3K+ Views

The DateTime.IsLeapYear() method in C# is used to check whether the specified year is a leap year. The return value is a boolean, with TRUE if the year is a leap year, else FALSE.SyntaxFollowing is the syntax −public static bool IsLeapYear (int y);Above, y is the year to be checked, 2010, 2016, 2019, etc.ExampleLet us now see an example to implement the DateTime.IsLeapYear() method −using System; public class Demo {    public static void Main() {       int year = 2019;       Console.WriteLine("Year = "+year);       if (DateTime.IsLeapYear(year)){          Console.WriteLine("Leap Year!"); ... Read More

DateTime IsDaylightSavingTime Method in C#

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

407 Views

The DateTime.IsDaylightSavingTime() method in C# is used to indicate whether this instance of DateTime is within the daylight saving time range for the current time zone.SyntaxFollowing is the syntax −public bool IsDaylightSavingTime ();ExampleLet us now see an example to implement the DateTime.IsDaylightSavingTime() method −using System; public class Demo {    public static void Main() {       DateTime d = new DateTime(2019, 10, 11, 7, 10, 40);       bool res = d.IsDaylightSavingTime();       if (res)          Console.WriteLine("TRUE: This instance of DateTime is within the daylight saving time range for the current time ... Read More

Delete URLs with Specific Domains from MySQL Database

AmitDiwan
Updated on 08-Nov-2019 10:39:25

336 Views

To delete URLs with specific domains, use DELETE and LIKE clause.Let us first create a table −mysql> create table DemoTable1361     -> (     -> URL text     -> ) ; Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1361 values('Https://www.google.com//?id=1'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1361 values('Https://www.facebook.com//?id=2&name=John'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1361 values('Https://www.yahoo.com//?id=3'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1361 values('Https://www.google.com//?id=1'); Query OK, 1 row affected (0.16 sec)Display all records from ... Read More

DateTime GetTypeCode Method in C#

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

79 Views

he DateTime.GetTypeCode() method in C# is used to return the TypeCode for value type DateTime. The returned value is the enumerated constant, DateTime.SyntaxFollowing is the syntax −public TypeCode GetTypeCode ();ExampleLet us now see an example to implement the DateTime.GetTypeCode() method −using System; public class Demo {    public static void Main() {       DateTime d = DateTime.Now;       TypeCode res = d.GetTypeCode();       Console.WriteLine("TypeCode of Date {0} = {1} ", d, res);    } }OutputThis will produce the following output −TypeCode of Date 10/16/2019 7:08:50 AM = DateTimeExampleLet us now see another example to ... Read More

Get Current Year in MySQL WHERE Clause

AmitDiwan
Updated on 08-Nov-2019 10:37:28

793 Views

To get current year, use YEAR() along with CURDATE(). Let us first create a table −mysql> create table DemoTable1360     -> (     -> JoiningYear int     -> )     -> ; Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1360 values(1998); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1360 values(2018); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1360 values(2016); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1360 values(2019); Query OK, 1 row affected (0.13 sec) mysql> ... Read More

Get Hash Code Method in C#

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

650 Views

The DateTime.GetHashCode() method in C# is used to returns the hash code for this instance. This return value is a 32-bit signed integer hash code.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the DateTime.GetHashCode() method −using System; public class Demo {    public static void Main() {       DateTime d = new DateTime(2019, 11, 10, 7, 20, 45);       int res = d.GetHashCode();       Console.WriteLine("HashCode for date {0} = {1}", d, res);    } }OutputThis will produce the following output −HashCode for date 11/10/2019 7:20:45 AM ... Read More

Advertisements