Match Elements of an Array in a MySQL Query

AmitDiwan
Updated on 11-Dec-2019 06:33:22

2K+ Views

Let us first create a table table −mysql> create table DemoTable1523    -> (    -> Id int,    -> Value int    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1523 values(1, 56); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1523 values(2, 78); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1523 values(1, 34); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1523 values(2, 45); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1523 values(1, 99); Query OK, ... Read More

Check HybridDictionary for Specific Key in C#

AmitDiwan
Updated on 11-Dec-2019 06:32:29

123 Views

To check the HybridDictionary for a specified key, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       HybridDictionary dict = new HybridDictionary(5);       dict.Add("A", "AB");       dict.Add("B", "BC");       dict.Add("C", "DE");       dict.Add("D", "FG");       dict.Add("E", "HI");       Console.WriteLine("Key/Value pairs...");       foreach(DictionaryEntry d in dict)       Console.WriteLine("Key = "+d.Key + ", Value = " + d.Value);       Console.WriteLine("Does HybridDictionary contains the key C? = "+dict.Contains("C"));    } ... Read More

What is an Event Object in jQuery

Ricky Barnes
Updated on 11-Dec-2019 06:32:29

435 Views

The callback function takes a single parameter; when the handler is called the JavaScript event object will be passed through it.The event object is often unnecessary and the parameter is omitted, as sufficient context is usually available when the handler is bound to know exactly what needs to be done when the handler is triggered, however there are certain attributes which you would need to be accessed.Let us see an example of isDefaultPrevented() method. The isDefaultPrevented() method checks whether event.preventDefault() was ever called on this event object.ExampleYou can try to run the following code to learn how to work with ... Read More

Sum Columns Corresponding Values According to Similar Dates in MySQL

AmitDiwan
Updated on 11-Dec-2019 06:31:06

225 Views

For this, use aggregate function SUM() along with GROUP BY. Let us first create a table −mysql> create table DemoTable1522    -> (    -> ProductPurchaseDate date,    -> NumberOfProduct int    -> ); Query OK, 0 rows affected (1.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1522 values('2019-01-21', 45); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1522 values('2018-12-31', 78); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1522 values('2019-01-21', 67); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1522 values('2019-03-01', 56); Query OK, 1 row affected (0.19 ... Read More

Convert Class in C#

AmitDiwan
Updated on 11-Dec-2019 06:29:45

732 Views

The Convert Class has methods to convert a base data type to another base data type. Let us see some examples −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 − Live Demousing System; using System.Globalization; public class Demo {    public static void Main(){       ... Read More

Update Column in MySQL and Remove Trailing Underscore Values

AmitDiwan
Updated on 11-Dec-2019 06:27:28

559 Views

To remove the trailing values, use TRIM() as in the below update syntax −update yourTableName set yourColumnName=trim(trailing '_' from yourColumnName);Let us first create a table −mysql> create table DemoTable1521    -> (    -> StudentCode varchar(20)    -> ); Query OK, 0 rows affected (1.33 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1521 values('345_'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1521 values('12345'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable1521 values('9084_'); Query OK, 1 row affected (1.29 sec)Display all records from the table using select statement −mysql> select ... Read More

Char Struct in C#

AmitDiwan
Updated on 11-Dec-2019 06:26:39

419 Views

The Char Struct in C# represents a character as a UTF-16 code unit. Here are some of the methods −MethodDescriptionConvertToUtf32(Char, Char)Converts the value of a UTF-16 encoded surrogate pair into a Unicode code point.ConvertToUtf32(String, Int32)Converts the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point.Equals(Char)Returns a value that indicates whether this instance is equal to the specified Char object.Equals(Object)Returns a value that indicates whether this instance is equal to a specified object.GetHashCode()Returns the hash code for this instance.GetNumericValue(Char)Converts the specified numeric Unicode character to a double-precision floating-point number.IsDigit(String, ... Read More

Insert Records from One MySQL Table to Another

AmitDiwan
Updated on 11-Dec-2019 06:25:16

182 Views

For this, you can use the concept of CREATE TABLE AS SELECT statement. Let us first create a table −mysql> create table DemoTable1518    -> (    -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> EmployeeName varchar(20)    -> )AUTO_INCREMENT=101; Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1518(EmployeeName) values('John Doe'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1518(EmployeeName) values('John Smith'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1518(EmployeeName) values('David Miller'); Query OK, 1 row affected (0.14 sec)Display all records from the ... Read More

Standard Output and Error Stream in C#

AmitDiwan
Updated on 11-Dec-2019 06:24:33

661 Views

To get the standard output stream through Console, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(string[] args){       Console.WriteLine("Standard Output Stream = "+Console.Out);    } }OutputThis will produce the following output −Standard Output Stream = System.IO.TextWriter+SyncTextWriterExampleTo get the standard error output stream through Console, the code is as follows − Live Demousing System; public class Demo {    public static void Main(string[] args){       Console.WriteLine("Standard Output Stream = "+Console.Out);       Console.WriteLine("Standard Error Output Stream = "+Console.Error);    } }OutputThis will produce the following output −Standard Output ... Read More

Select Data from One Table Where Column Values Match Another Table in MySQL

AmitDiwan
Updated on 11-Dec-2019 06:23:25

4K+ Views

For this, you can use subquery along with EXISTS. Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int,    -> SubjectName varchar(20)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(111, 'MySQL'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1 values(112, 'MongoDB'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1 values(113, 'Java'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1 values(114, 'C'); Query OK, 1 row affected (0.27 sec) ... Read More

Advertisements