Find All Tables Containing Two Specific Columns in MySQL

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

700 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

189 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

421 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

346 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

106 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

817 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

664 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

Using Backticks in Contact Gives an Error in MySQL

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

164 Views

Do not use backticks, you can use single quotes in CONCAT(). Following is the syntax −select concat(yourColumnName1, ' ', yourColumnName2) from yourTableName;Let us first create a table −mysql> create table DemoTable1359     -> (     -> Id int,     -> Name varchar(20)     -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1359 values(101, 'Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1359 values(102, 'Adam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1359 values(103, 'Mike'); Query OK, 1 row ... Read More

Get DateTime Formats in C#

AmitDiwan
Updated on 08-Nov-2019 10:34:11

1K+ Views

The DateTime.GetDateTimeFormats() method in C# is used to convert the value of this instance to all the string representations supported by the standard date and time format specifiers.SyntaxFollowing is the syntax −public string[] GetDateTimeFormats () public string[] GetDateTimeFormats (char ch);Above, ch is a standard date and time format string.ExampleLet us now see an example to implement the DateTime.GetDateTimeFormats() method −using System; public class Demo {    public static void Main() {       DateTime d = new DateTime(2019, 11, 10, 7, 20, 45);       string[] res = d.GetDateTimeFormats();       foreach(string s in res)     ... Read More

Advertisements