Order and Select Query with Conditions in MySQL

AmitDiwan
Updated on 05-Nov-2019 09:25:38

247 Views

Following is the syntax −select * from yourTableName order by yourColumnName=0, yourColumnName;Let us first create a table −mysql> create table DemoTable1348    -> (    -> Amount int    -> ); Query OK, 0 rows affected (0.80 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1348 values(100); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1348 values(0); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1348 values(90); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1348 values(45); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1348 values(0); Query ... Read More

Update a Column Based on Another MySQL Table's Column

AmitDiwan
Updated on 05-Nov-2019 09:23:40

599 Views

For this, you can use the join concept. Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int,    -> Name varchar(10)    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(100, 'Bob'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select * from DemoTable1;This will produce the following output −+------+------+ | Id | Name | +------+------+ | 100 | Bob | +------+------+ 1 row in set (0.00 ... Read More

char_convertToUTF32_String_Int32 Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:13:24

308 Views

The Char.ConvertToUtf32(String, Int32) method in C# is used to convert the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point.SyntaxFollowing is the syntax −public static int ConvertToUtf32 (string str, int index);Above, str is the string that contains a character or surrogate pair. The index parameter is the index position of the character or surrogate pair in str.ExampleLet us now see an example to implement the Char.ConvertToUtf32(String, Int32) method −using System; public class Demo {    public static void Main(){       int utf = 0x046;     ... Read More

Mask User Email Addresses with Different Domain in MySQL

AmitDiwan
Updated on 05-Nov-2019 08:40:59

506 Views

Let us first create a table −mysql> create table DemoTable1345    -> (    -> UserEmailAddress text    -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command. We have inserted email address here −mysql> insert into DemoTable1345 values('Carol123@gmail.com'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1345 values('987Sam@gmail.com'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1345 values('David_Miller@gmail.com'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1345 values('Bob@gmail.com'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select * ... Read More

Convert ToBoolean String IFormatProvider Method in C#

AmitDiwan
Updated on 05-Nov-2019 08:15:27

429 Views

The Convert.ToBoolean() method in C# is used to convert a specified value to an equivalent Boolean value.SyntaxFollowing is the syntax −public static bool ToBoolean (string val, IFormatProvider provider);Above, Val is a string that contains the value of either TrueString or FalseString, whereas the provider is an object that supplies culture-specific formatting information.ExampleLet us now see an example to implement the Convert.ToBoolean() method −using System; using System.Globalization; public class Demo {    public static void Main(){       CultureInfo cultures = new CultureInfo("en-US");       String str = "true";       Console.WriteLine("Converted bool value...");       bool ... Read More

DaysInMonth Method in C#

AmitDiwan
Updated on 05-Nov-2019 08:12:53

3K+ Views

The DateTime.DaysInMonth() method in C# is used to return the number of days in the specified month and year. For example, 31 for month value 1 i.e. January.SyntaxFollowing is the syntax −public static int DaysInMonth (int year, int month);ExampleLet us now see an example to implement the DateTime.DaysInMonth() method −using System; public class Demo {    public static void Main() {       DateTime date1 = new DateTime(2019, 08, 20, 6, 20, 40);       DateTime date2 = new DateTime(2019, 06, 20, 6, 20, 40);       Console.WriteLine("DateTime 1 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", date1);     ... Read More

uint16 MaxValue Field in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 08:10:12

404 Views

The UInt16.MaxValue field in C# represents the maximum value of the 16-bit unsigned integer.SyntaxFollowing is the syntax −public const ushort MaxValue = 65535;ExampleLet us now see an example to implement the UInt16.MaxValue field −using System; public class Demo {    public static void Main(){       ushort val1 = 23;       ushort val2 = 0;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("HashCode for value1 = "+val1.GetHashCode());       Console.WriteLine("HashCode for value2 = "+val2.GetHashCode());       Console.WriteLine("Are they equal? = "+(val1.Equals(val2)));       TypeCode type1 = ... Read More

UInt16 GetTypeCode Method in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 08:04:27

98 Views

The UInt16.GetTypeCode() method in C# is used to return the TypeCode for value type UInt16.SyntaxFollowing is the syntax −public TypeCode GetTypeCode ();ExampleLet us now see an example to implement the UInt16.GetTypeCode() method −using System; public class Demo {    public static void Main(){       ushort val1 = 55;       ushort val2 = 100;       TypeCode type1 = val1.GetTypeCode();       TypeCode type2 = val2.GetTypeCode();       Console.WriteLine("Typecode for val1 = "+type1);       Console.WriteLine("Typecode for val1 = "+type2);    } }OutputThis will produce the following output −Typecode for val1 = UInt16 ... Read More

uint16 GetHashCode Method in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 07:59:29

130 Views

The UInt16.GetHashCode() method in C# is used to get the HashCode for the current UInt16 instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the UInt16.GetHashCode() method −using System; public class Demo {    public static void Main(){       ushort val1 = 100;       ushort val2 = UInt16.MinValue;       Console.WriteLine("HashCode for val1 = "+val1.GetHashCode());       Console.WriteLine("HashCode for val2 = "+val2.GetHashCode());    } }OutputThis will produce the following output −HashCode for val1 = 100 HashCode for val2 = 0ExampleLet us now see another example to implement ... Read More

Tuple t1 t2 Class in C#

AmitDiwan
Updated on 05-Nov-2019 07:57:04

151 Views

The Tuple class represents a 2-tuple, which is called pair. A tuple is a data structure that has a sequence of elements.It is used in −Easier access to a data set.Easier manipulation of a data set.To represent a single set of data.To return multiple values from a methodTo pass multiple values to a methodIt has two properties −Item1 − Get the value of the current Tuple object's first component.Item2 − Get the value of the current Tuple object's second component.ExampleLet us now see an example to implement the 2-tuple in C# −using System; public class Demo {    public static ... Read More

Advertisements