George John has Published 1234 Articles

MySQL order by string with numbers?

George John

George John

Updated on 30-Jun-2020 07:20:00

4K+ Views

To MySQL order string with numbers, the following is the syntax, wherein we have used ORDER BY, SUBSTR() and CAST() −SELECT *FROM yourTableName ORDER BY SUBSTR(yourColumnName FROM 1 FOR 2), CAST(SUBSTR(yourColumnName FROM 2) AS UNSIGNED);To understand the above syntax, let us create a table. The query to create a table ... Read More

MySQL select * with distinct id?

George John

George John

Updated on 30-Jun-2020 07:06:04

2K+ Views

You can use GROUP BY command for select with distinct id. The syntax is as follows −SELECT *FROM yourTableName GROUP BY yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table DistinctIdDemo    -> (    -> Id ... Read More

Select distinct combinations from two columns in MySQL?

George John

George John

Updated on 30-Jun-2020 06:53:01

4K+ Views

To select distinct combinations from two columns, you can use CASE statement. Let us create a table with some columns.The query to create a table is as follows −mysql> create table select_DistinctTwoColumns    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> FirstValue char(1),    -> SecondValue char(1), ... Read More

Order by last 3 chars in MySQL?

George John

George John

Updated on 30-Jun-2020 06:48:25

14K+ Views

You can use ORDER BY RIGHT() function to order by last 3 chars in MySQL. The syntax is as follows −SELECT *FROM yourTableName ORDER BY RIGHT(yourColumnName, 3) yourSortingOrder;Just replace the ‘yourSortingOrder’ to ASC or DESC to set the ascending or descending order respectively.To understand the above syntax, let us create ... Read More

What are intent-filters in Android?

George John

George John

Updated on 30-Jun-2020 05:29:17

4K+ Views

An intent filter is an instance of the IntentFilter class. Intent filters are helpful while using implicit intents, It is not going to handle in java code, we have to set it up in AndroidManifest.xml. Android must know what kind of intent it is launching so intent filters give the ... Read More

Loop through an ArrayList using an Iterator in Java

George John

George John

Updated on 29-Jun-2020 13:56:42

4K+ Views

An Iterator can be used to loop through an ArrayList. The method hasNext( ) returns true if there are more elements in ArrayList and false otherwise. The method next( ) returns the next element in the ArrayList and throws the exception NoSuchElementException if there is no next element.A program that ... Read More

How to add line break for UILabel in iOS/iPhone?

George John

George John

Updated on 29-Jun-2020 13:52:56

2K+ Views

Line break in a UILabel is used to change how the text appears on a label. Suppose a label has text more than two lines but by default the Line break in a UILabel is used to change how the text appears on a label. Suppose a label has text ... Read More

Replace an element in an ArrayList using the ListIterator in Java

George John

George John

Updated on 29-Jun-2020 13:47:32

917 Views

An element in ArrayList can be replaced using the ListIterator method set(). This method has a single parameter i.e. the element that is to be replaced and the set() method replaces it with the last element returned by the next() or previous() methods.A program that demonstrates this is given as ... Read More

Iterate through ArrayList in Java

George John

George John

Updated on 29-Jun-2020 13:36:44

6K+ Views

The iterator can be used to iterate through the ArrayList wherein the iterator is the implementation of the Iterator interface. Some of the important methods declared by the Iterator interface are hasNext() and next().The hasNext() method returns true if there are more elements in the ArrayList and otherwise returns false. ... Read More

Traverse TreeSet elements in descending order in java

George John

George John

Updated on 29-Jun-2020 13:26:15

312 Views

Create TreeSet and add elements to itTreeSet tSet = new TreeSet(); tSet.add("P"); tSet.add("Q"); tSet.add("R"); tSet.add("S");Now, let us traverse elements in descending orderIterator j = tSet.descendingIterator(); while(j.hasNext()) {    System.out.println(j.next()); }The following is an example to traverse TreeSet elements in descending orderExample Live Demoimport java.util.*; public class Demo {    public static ... Read More

Previous 1 ... 5 6 7 8 9 ... 124 Next
Advertisements