Count Values Based on Conditions in MySQL

AmitDiwan
Updated on 05-Nov-2019 07:15:06

154 Views

Let us first create a table −mysql> create table DemoTable1485     -> (     -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,     -> StudentName varchar(20),     -> StudentSubject varchar(20)     -> ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1485(StudentName, StudentSubject) values('Chris', 'MySQL'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1485(StudentName, StudentSubject) values('Robert', 'MongoDB'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1485(StudentName, StudentSubject) values('Robert', 'MongoDB'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1485(StudentName, StudentSubject) ... Read More

jQuery Empty Selector

AmitDiwan
Updated on 05-Nov-2019 07:13:15

254 Views

The :empty selector in jQuery is used to select all elements which are empty.SyntaxThe syntax is as follows −$(":empty")ExampleLet us now see an example to implement the :empty() selector −    .demo {       color: brown;       background-color: orange;       font-size: 16px;       border: 2px blue dashed;       width:100px;       height:70px;    }    $(document).ready(function(){       $("p:empty(.one)").addClass("demo");    }); Enter details ID: Rank: Fav. Subjects: Maths: English OutputThis will produce the following output −

Using MySQL WHERE Clause and Ordering by AVG to Find Average of Duplicates

AmitDiwan
Updated on 05-Nov-2019 07:12:03

244 Views

For this, use having clause instead of where. Let us first create a table −mysql> create table DemoTable1338    -> (    -> Name varchar(10),    -> Score int    -> ); Query OK, 0 rows affected (1.54 sec)Insert some records in the table using insert command. Here, we have inserted duplicate names with scores −mysql> insert into DemoTable1338 values('Chris', 8); Query OK, 1 row affected (0.80 sec) mysql> insert into DemoTable1338 values('Bob', 4); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1338 values('Bob', 9); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1338 values('Chris', 6); ... Read More

Tuple T1 Class in C#

AmitDiwan
Updated on 05-Nov-2019 07:11:46

132 Views

The Tuple class represents a 1-tuple, which is called singleton. 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 one property −Item1 − Get the value of the current Tuple object's first component.ExampleLet us now see an example to implement the 1-tuple in C# −using System; public class Demo {    public static void Main(string[] args) {       Tuple tuple = new ... Read More

Fetch Maximum Value from Column with String Numbers in SQL

AmitDiwan
Updated on 05-Nov-2019 07:08:47

106 Views

For this, you can use MAX() along with substring(). Let us first create a table −mysql> create table DemoTable1337    -> (    -> Value varchar(50)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1337 values('Value400'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1337 values('Value345'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1337 values('Value567'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1337 values('Value489'); Query OK, 1 row affected (0.22 sec)Display all records from the table using select statement ... Read More

Tuple Class in C#

AmitDiwan
Updated on 05-Nov-2019 07:08:31

276 Views

If you want to return more than one value from a class method, then use C# Tuples. To create tuples in C#< this class provides a static method. Tuples introduced in .NET 4.0.ExampleLet us now see an example to implement Tuple in C# −using System; public class Demo {    public static void Main(string[] args) {       Tuple tuple = new Tuple(2, "Tom");       if (tuple.Item1 == 150) {          Console.WriteLine(tuple.Item1);       }       if (tuple.Item2 == "Tom") {          Console.WriteLine(tuple.Item2);       }    } }OutputThis will produce the following output −Tom

jQuery Disabled Selector

AmitDiwan
Updated on 05-Nov-2019 07:07:30

301 Views

The :disabled() selector in jQuery is used to select all disabled input elements.SyntaxThe syntax is as follows −$(":disabled")ExampleLet us now see an example to implement the :disabled() selector −    .one {       color: brown;       background-color: orange;       font-size: 16px;       border: 2px blue dashed;    }    $(document).ready(function(){       $(":disabled").addClass("one");    }); ID: Rank: Fav. Subjects: Maths: English OutputThis will produce the following output −

Display All Grants of a Specific User in MySQL

AmitDiwan
Updated on 05-Nov-2019 07:05:58

181 Views

Let us first 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            | %         | | mysql.infoschema | %         ... Read More

Math Truncate Method in C#

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

609 Views

The Math.Truncate() method in C# is used to compute an integral part of a number, which is Double or Decimal.Syntaxpublic static decimal Truncate(decimal val1) public static double Truncate(double val2)Above, there are two syntaxes. The value val1 is the decimal number to truncate, whereas val2 is the double number to truncate.ExampleLet us now see an example to implement Math.Truncate() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 25.46467m;       Decimal val2 = 45.9989m;       Decimal val3 = 678.325m;       Console.WriteLine(Math.Truncate(val1));       Console.WriteLine(Math.Truncate(val2));   ... Read More

jQuery Contains Selector

AmitDiwan
Updated on 05-Nov-2019 07:03:51

514 Views

The :contain() selector in jQuery is used to select elements containing the specified text.SyntaxThe syntax is as follows −$(":contains(text)")Here, the parameter text is the text to find. The same elements are selected with the specified text.ExampleLet us now see an example to implement the :contains() selector −    .one {       color: brown;       background-color: orange;       font-size: 16px;       border: 2px blue dashed;    }    $(document).ready(function(){       $("p:contains(the)").addClass("one");    }); Examination Timings: 10AM - 1PM The examination hall details would be emailed to the students. OutputThis will produce the following output −

Advertisements