To concatenate more than 2 fields with SQL, you can use CONCAT() or CONCAT_WS() function. The syntax is as follows. Let us first see using CONCAT().SELECT CONCAT(yourColumnName1, '/', yourColumnName2, '/', yourColumnName3, '/', ......N) AS anyVariableName FROM yourTableName;The syntax is as follows:SELECT CONCAT_WS(‘/’, yourColumnName1, yourColumnName2, .....N) AS anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table MoreThan2ColumnConcat -> ( -> Id int, -> Name varchar(20), -> Age int, -> Marks int -> ); Query OK, 0 rows affected (2.59 sec)Insert some ... Read More
We will see here how to display all tables inside a MySQL database using Java. You can use show command from MySQL to get all tables inside a MySQL database.Let’s say our database is ‘test’. The Java code is as follows to show all table names inside a database ‘test’.The Java code is as follows. Here, connection is established between MySQL and Java −import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import com.mysql.jdbc.Connection; import com.mysql.jdbc.DatabaseMetaData; public class GetAllTables { public static void main(String[] args) throws SQLException { Connection conn = null; try { ... Read More
A single action can be performed in multiple ways using the concept of polymorphism. Run-time polymorphism can be performed by method overriding. The overridden method in this is resolved at compile time.A program that demonstrates run-time polymorphism in Java is given as follows:Example Live Democlass Animal { void sound() { System.out.println("Animal makes sound"); } } class Cat extends Animal { void sound() { System.out.println("Cat Meows"); } } class Dog extends Animal { void sound() { System.out.println("Dog Barks"); } } class Cow extends Animal { void ... Read More
In MySQL, convert datetime to integer using UNIX_TIMESTAMP() function. The syntax is as follows:SELECT UNIX_TIMESTAMP(yourDatetimeColumnName) as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table DatetimeToInteger -> ( -> Id int NOT NULL AUTO_INCREMENT, -> ArrivalTime datetime, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.94 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into DatetimeToInteger(ArrivalTime) values(now()); Query OK, 1 row affected (0.09 sec) mysql> insert into DatetimeToInteger(ArrivalTime) values(curdate()); Query OK, 1 ... Read More
To clone the IdentityHashMap in Java, use the clone() method.Create an IdentityHashMap and add elements to it −IdentityHashMap m = new IdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110);Now get the size of the IdentityHashMap −m.size()The following is an example to clone IdentityHashMap in Java −Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { IdentityHashMap m = new IdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); ... Read More
In some situation, we need to find an android activity orientation. This example demonstrates how to integrate Android Login and registration form.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken a text view. According to screen orientation, text view going to update the text.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; ... Read More
To get order by column and place empty records at the end, use ORDER By and “is null” from MySQL. The syntax is as follows −select *from yourTableName order by if(yourColumName = ’ ’ or yourColumName is null, 1, 0), yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table emptyCellsAtEnd −> ( −> ProductId varchar(100) −> ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command. Some of these records are empty. The query is as follows −mysql> ... Read More
To renew a distribution certificate on mac we’ll have to go through a series of steps mentioned below.Use spotlight to open keychain access on your macFrom keychain access menu select Certificate Assistant -> Request certificate from certificate Authority.Fill the information there like Name, email and choose “save to disk”.Click continue and save to your desired location. This will generate a .CSR file which we’ll need to upload to the developer portal while generating our certificate.Go to “developer.apple.com”, login to your account, select “Certificates, IDs & Profiles”.Go to certificates, select production and click on the “+” on the topSelect "App Store ... Read More
Here are some of the most common and simple to explain reasons for leaving a job:The desire to learn.The desire to take on more responsibility.The desire to take on less responsibility.The desire to relocate.The desire for a career change.The desire to gain a new skill or grow a current skill.The company reorganization has led to a change in job content.The desire for a shorter commute to work.The desire to improve work/life balance.
A class declaration can contain a String instance and methods to set and get its value in Java.A program that demonstrates this is given as follows:Example Live Democlass Name { private String name; public void setName(String n) { name = n; } public String getName() { return name; } } public class Demo { public static void main(String[] args) { Name n = new Name(); n.setName("John Smith"); System.out.println("The name is: " + n.getName()); } }OutputThe name is: John SmithNow ... Read More