Insert From One Table with Different Structure to Another in MySQL

AmitDiwan
Updated on 12-Dec-2019 05:24:49

591 Views

For this, use INSERT INTO SELECT statement. Let us first create a table −mysql> create table DemoTable1    -> (    -> PersonId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> PersonName varchar(20),    -> PersonAge int,    -> PersonCountryName varchar(20)    -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(PersonName, PersonAge, PersonCountryName) values('Chris Brown', 24, 'US'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1(PersonName, PersonAge, PersonCountryName) values('John Doe', 26, 'UK'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1(PersonName, PersonAge, PersonCountryName) values('David ... Read More

Group By and Count in a Single MySQL Query

AmitDiwan
Updated on 12-Dec-2019 05:23:39

235 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> ClientId int,    -> Value int    -> ); Query OK, 0 rows affected (0.79 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 678); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(20, 678); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(30, 678); Query OK, 1 row affected (0.09 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----------+-------+ | ClientId | Value ... Read More

Fetch Multiple MySQL Rows Based on Specific Input

AmitDiwan
Updated on 12-Dec-2019 05:21:22

283 Views

Let us first create a table −mysql> create table DemoTable1528    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> StudentSubject varchar(20)    -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1528(StudentName, StudentSubject) values('Chris', 'MongoDB'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable1528(StudentName, StudentSubject) values('Bob', 'MySQL'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1528(StudentName, StudentSubject) values('David', 'Java'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1528(StudentName, StudentSubject) values('Carol', 'C'); Query OK, 1 ... Read More

Insert Records with Double Quotes in MySQL

AmitDiwan
Updated on 12-Dec-2019 05:20:26

3K+ Views

To insert records with double quotes, use the backslash (\) as in the below syntax −Syntaxinsert into yourTableName values('\"yourValue\"');Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('\"John\"'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('\"Chris\"'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('\"Adam Smith\"'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('\"Carol\"'); Query OK, 1 row affected ... Read More

Display Only Hour and Minutes in MySQL

AmitDiwan
Updated on 12-Dec-2019 05:17:29

3K+ Views

To display only hour and minutes, use DATE_FORMAT() and set format specifiers as in the below syntax −select date_format(yourColumnName, '%H:%i') as anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable1527    -> (    -> ArrivalDatetime datetime    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1527 values('2019-01-10 12:34:45'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1527 values('2018-12-12 11:00:34'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1527 values('2019-03-21 04:55:56'); Query OK, 1 row affected (0.18 sec)Display all records from ... Read More

Order By Last 3 Months First Then Alphabetically in MySQL

AmitDiwan
Updated on 12-Dec-2019 05:14:51

390 Views

Let us first create a table −mysql> create table DemoTable1526    -> (    -> CustomerName varchar(20),    -> PurchaseDate date    -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command. Here, we have inserted 2019 dates −mysql> insert into DemoTable1526 values('Adam', '2019-06-01'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1526 values('Sam', '2019-04-26'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1526 values('Chris', '2019-05-24'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1526 values('David', '2019-10-10'); Query OK, 1 row affected (0.23 sec) mysql> insert into ... Read More

Future of Selenium Automation Testing as a Career Option

Adiya Dua
Updated on 11-Dec-2019 12:44:44

331 Views

We are now living in a world of Cloud and Digital business. Application Development of almost all the platform is in boom. For providing utmost customer satisfaction, the application has to be seamless and bug-free.We have been living in the age of manual testing since very long. We have new requirements pitching in every now-and-then from the clients where there is either enhancement in the application or any modification. For testing these new requirements, we need to run the older test cases repeatedly to test if it is not affected by the new change. And we end up testing the ... Read More

Learn Selenium Without Knowing Java

Adiya Dua
Updated on 11-Dec-2019 12:38:47

635 Views

This Question comes to many professionals who are not actually into core technical and want to pursue their career in Selenium Automation. The term coding makes the non-programmers a bit scare to even start off with something like automation. There is a perception that a non-programmer cannot excel in Automation, but it is only in head. Many deserving and capable manual testers shy away from Selenium just thinking that it require some special skills.There are various many languages in which Selenium Scripts are designed such as Python, Ruby, C#, JavaScript and Java is one such of them. Knowing the popularity ... Read More

Variables Accessible in a Lambda Expression in Java

raja
Updated on 11-Dec-2019 12:30:52

1K+ Views

The lambda expressions consist of two parts, one is parameter and another is an expression and these two parts have separated by an arrow (->) symbol. A lambda expression can access a variable of it's enclosing scope. A Lambda expression has access to both instance and static variables of it's enclosing class and also it can access local variables which are effectively final or final.Syntax( argument-list ) -> expressionExampleinterface TestInterface {    void print(); } public class LambdaExpressionTest {    int a; // instance variable    static int b; // static variable    LambdaExpressionTest(int x) {    // constructor to initialise instance variable       this.a = ... Read More

Fetch Maximum Value from a MySQL Column

AmitDiwan
Updated on 11-Dec-2019 11:49:37

218 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(98); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(58); Query OK, 1 row affected (0.25 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output ... Read More

Advertisements