Use NOT IN() to exclude some of the values from the table.Let us first create a table −mysql> create table DemoTable791 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable791(FirstName) values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable791(FirstName) values('Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable791(FirstName) values('David'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable791(FirstName) values('Mike'); Query OK, 1 row affected (0.11 ... Read More
Let us first create a table −mysql> create table DemoTable790 ( Score1 int, Score2 int ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command −mysql> insert into DemoTable790 values(98, 76); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable790 values(78, 89); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable790 values(85, 68); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable790;This will produce the following output -+--------+--------+ | Score1 | Score2 | +--------+--------+ ... Read More
To check for the 1st letter of the first and last name, you need to use the LEFT().Let us first create a table −mysql> create table DemoTable789 ( FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into DemoTable789 values('Adam', 'Smith'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable789 values('Tom', 'Taylor'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable789 values('Bob', 'Brown'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable789 values('David', 'Miller'); Query ... Read More
Use ORDER BY to sort data for duplicate record.Let us first create a table −mysql> create table DemoTable788 ( FirstName varchar(100), Score int ); Query OK, 0 rows affected (1.89 sec)Insert some records in the table using insert command −mysql> insert into DemoTable788 values('Chris', 78); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable788 values('Robert', 67); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable788 values('Chris', 98); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable788 values('Chris', 56); Query OK, 1 row affected (0.15 sec) mysql> insert into ... Read More
Let us first create a table −mysql> create table DemoTable787 ( Score1 int, Score2 int, Name varchar(100) ); Query OK, 0 rows affected (0.84 sec)Insert some records in the table using insert command −mysql> insert into DemoTable787 values(34, 56, 'Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable787 values(73, 86, 'Robert'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable787 values(90, 99, 'David'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable787 values(80, 89, 'Adam'); Query OK, 1 row affected (0.21 sec)Display all records ... Read More
To display column values as CSV, use GROUP_CONCAT().Let us first create a table −mysql> create table DemoTable786 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ) AUTO_INCREMENT=101; Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable786(StudentName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable786(StudentName) values('Robert'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable786(StudentName) values('Mike'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable786(StudentName) values('Sam'); Query OK, 1 row affected (0.12 sec)Display all records from the table ... Read More
For specific day of week, use DAYOFWEEK().Let us first create a table −mysql> create table DemoTable785 ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(100), ShoppingDate date ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable785(CustomerName, ShoppingDate) values('Chris', '2019-07-03'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable785(CustomerName, ShoppingDate) values('Robert', '2019-07-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable785(CustomerName, ShoppingDate) values('David', '2019-07-06'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable785(CustomerName, ShoppingDate) ... Read More
Arrays in Java are used to store homogeneous datatypes, where generics allow users to dynamically choose the type (class) that a method, constructor of a class accepts, dynamically.By defining a class generic you are making it type-safe i.e. it can act up on any datatype. To understand generics let us consider an example −Example Live Democlass Student{ T age; Student(T age){ this.age = age; } public void display() { System.out.println("Value of age: "+this.age); } } public class GenericsExample { public static void main(String args[]) { Student ... Read More
Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.To define a generic class you need to specify the type parameter you are using in the angle brackets “” after the class name and you can treat this as datatype of the instance variable an ... Read More
Similar to generic classes you can also define generic methods in Java. These methods use their own type parameters. Just like local variables, the scope of the type parameters of the methods lies within the method.While defining a generic method you need to specify the type parameter within the angle brackets (< T >). This should be placed before the method's return type.You can have multiple type parameters separated by commas. A type parameter, also known as a type variable, is an identifier that specifies a generic type name.The type parameters can be used to declare the return type and ... Read More