Group By to Concatenate Strings in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

9K+ Views

To concatenate strings in MySQL with GROUP BY, you need to use GROUP_CONCAT() with a SEPARATOR parameter which may be comma(‘) or space (‘ ‘) etc.The syntax is as follows:SELECT yourColumnName1, GROUP_CONCAT(yourColumnName2 SEPARATOR ‘yourValue’) as anyVariableName FROM yourTableName GROUP BY yourColumnName1;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table GroupConcatenateDemo    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert command. The query to insert record is as follows:mysql> insert ... Read More

Divide One BigDecimal from Another in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

181 Views

Use the divide method to divide one BigDecimal to another in Java. The method returns a BigDecimal whose value is (this / divisor), and whose preferred scale is (this.scale() - divisor.scale()).If the exact quotient cannot be represented (because it has a non-terminating decimal expansion) an ArithmeticException is thrown.The following is an example −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { BigDecimal val1 = new BigDecimal("37578975587"); BigDecimal val2 = new BigDecimal("62567875598"); System.out.println("Value 1 ... Read More

Strip Last Two Characters of a Column in MySQL

Anvi Jain
Updated on 30-Jul-2019 22:30:24

2K+ Views

You can strip last two characters with the help of SUBSTRING() and CHAR_LENGTH() methods. The syntax is as follows −select yourColumnName, SUBSTRING(yourColumnName, 1, CHAR_LENGTH(yourColumnName) - 2) AS anyVariableName from yourTableName;To understand the above syntax, let us create a table −mysql> create table LastTwoCharacters −> ( −> Words varchar(200) −> ); Query OK, 0 rows affected (0.71 sec)Now you can insert some records in the table with the help of select statement. The query to insert records is as follows −mysql> insert into LastTwoCharacters values('Hellooo'); Query OK, 1 row affected (0.23 sec) ... Read More

Get Current Version of iOS Project in Code

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

218 Views

When we build an iOS application, by default it get a version 1.0 and build 0. Whenever we upload a new build to the app store, we need to change the version number. We can update the build number for testing builds. The version and build number are stored in the info.plist file in our project.Sometimes we might need to access the build or the version number in our application to perform some custom action.To get the version number we can use the following code and assign it to a variable or constant.Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! StringTo get the build number ... Read More

Output MySQL Query Results in CSV Format on Screen

George John
Updated on 30-Jul-2019 22:30:24

672 Views

To get the output MySQL query result in CSV format, use concat(). The syntax is as follows −mysql> select concat(StudentId, ', ', StudentName, ', ', StudentAge) as CSVFormat from CSVFormatOutputs;To understand the above syntax, let us create a table. The query to create a table is as follows−mysql> create table CSVFormatOutputs    -> (    -> StudentId int not null auto_increment,    -> StudentName varchar(20),    -> StudentAge int,    -> PRIMARY KEY(StudentId)    -> ); Query OK, 0 rows affected (1.15 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into CSVFormatOutputs(StudentName, ... Read More

Mail Function in PHP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

375 Views

The mail() function allows in sending emails directly from a script.Syntaxmail(to,sub,msg,headers,parameters);Parametersto − The receiver / receivers of the emailsub − The subject of the email.msg − The message to be sent.headers − The additional headers, such as From, Cc, and Bcc.parameters − The additional parameter to the sendmail program. This was added in PHP 4.0.5.ReturnThe mail() function returns the hash value of the address parameter, or FALSE on failure.ExampleThe following is an example to send an email −

Negate a BigDecimal Value in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

375 Views

Use the negate() method to negate a BigDecimal value in Java. The method returns a BigDecimal whose value is (-this), and whose scale is this.scale().The following is an example −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { BigDecimal val1 = new BigDecimal("37578975587"); BigDecimal val2 = new BigDecimal("62567875598"); System.out.println("Value 1 : "+val1); System.out.println("Value 2 : "+val2); // division ... Read More

Display Hour in KK:00-11 Format in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

232 Views

The “KK” format in Java Date is used to display hour in 00-11.. Use SimpleDateFormat("KK") to get the same format −// displaying hour in KK format SimpleDateFormat simpleformat = new SimpleDateFormat("KK"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in KK format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More

Combine INSERT Values and SELECT in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

1K+ Views

You can combine the insert, values and select statement using below syntaxinsert into yourFirstTableName(yourColumnName1, yourColumnName2, .......N) select yourColumnName1, yourColumnName2, .......N from yourSecondTableName where yourCondition;To understand the above syntax, let us create two tables in which first table will get the record from the second table.Let us create the first table without any records. The query to create a table is as followsmysql> create table CombiningInsertValuesSelect    -> (    -> EmployeeId varchar(10),    -> EmployeeName varchar(100),    -> EmployeeAge int    -> ); Query OK, 0 rows affected (6.95 sec)Now you can create the second table with some records. The ... Read More

Processing Symbol Files Message in Xcode

Rishi Rathor
Updated on 30-Jul-2019 22:30:24

242 Views

Processing symbol files is a message displayed on xcode when we create a project’s build. When this message appears, in background Xcode downloads files and symbol files for specific device and a specific processor on which build shall be installed.The symbol files contains debug symbols which are used to debug on specific processor and iOS version and when some crash or error occurs, those symbols are used to create crash reports. Once processing symbols is done a new folder with device symbols is created in the library, usually under “~/Library/Developer/Xcode/iOS DeviceSupport/ “.Sometimes our system might get stuck on this step ... Read More

Advertisements