Karthikeya Boyini has Published 2383 Articles

MySQL query to select too many rows?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

405 Views

You can use LIMIT for this, which is used to fetch limited number of records. Let us first create a table −mysql> create table DemoTable (    Id int,    Name varchar(20) ); Query OK, 0 rows affected (0.53 sec)Insert records in the table using insert command −mysql> insert into ... Read More

Replace dot with comma on MySQL SELECT?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

5K+ Views

To replace dot with comma on SELECT, you can use REPLACE(). Following is the syntax −select replace(yourColumnName, '.' , ', ' ) from yourTableName;Let us first create a table −mysql> create table DemoTable (    Value float ); Query OK, 0 rows affected (0.63 sec)Insert records in the table using insert ... Read More

Retrieve all the keys from HashMap in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

308 Views

Let’s say the following is our HashMap −HashMapmap = new HashMap(); map.put(10, "A"); map.put(20, "B"); map.put(30, "C"); map.put(40, "D"); map.put(50, "E"); map.put(60, "F"); map.put(70, "G"); map.put(80, "H");To retrieve all the keys, iterator through each and every key-value pair −Setset = map.keySet(); Iteratori = set.iterator(); while (i.hasNext()) {    Integer res ... Read More

How to remove Duplicate Records except a single record in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

1K+ Views

You can use DELETE command with some condition for this since we need to keep one record and delete rest of the duplicate records.Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(40) ); Query OK, 0 rows ... Read More

Heap overflow and Stack overflow in C

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

5K+ Views

Heap OverflowHeap is used to store dynamic variables. It is a region of process’s memory. malloc(), calloc(), resize() all these inbuilt functions are generally used to store dynamic variables.Heap overflow occurs when −A) If we allocate dynamic large number of variables −int main() {    float *ptr = (int *)malloc(sizeof(float)*1000000.0)); ... Read More

How to use Iterator to loop through the Map key set?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

421 Views

First, create a HashMap, which is to be iterated −Mapmap = new LinkedHashMap(); map.put("Jack", "0"); map.put("Tim", "1"); map.put("David", "2"); map.put("Tom", "3"); map.put("Kevin", "4");Now, use Iterator to map through keyset −Iterator iterator = map.keySet().iterator();Iterate through all the pairs −while (iterator.hasNext()) {    String resKey = (String) iterator.next();    System.out.println("Rank of " ... Read More

Set MySQL int column to auto increment by 1 beginning at 10000?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

433 Views

Let us first create a table. Here, we have set UserId as AUTO_INCREMENT PRIMARY KEY −mysql> create table DemoTable (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK, 0 rows affected (0.72 sec)Following is the query to set int column to auto increment by 1 beginning at ... Read More

How to use poll() in android PriorityBlockingQueue?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

83 Views

Before getting into the example, we should know what PriorityBlockingQueue is. It is an unbounded queue and follows the same order as a priority queue. The main usage of priority blocking queue is, it going to handle out of memory error.This example demonstrates about How to use poll() in android ... Read More

How to subtract by 1 if the field value > 0 in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

271 Views

You can use CASE statement with UPDATE command for this. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value int ); Query OK, 0 rows affected (1.44 sec)Insert records in the table using insert command −mysql> insert into DemoTable(Value) ... Read More

Throwing exceptions from C++ constructors

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

1K+ Views

This is a simple example of throwing exceptions from C++ constructorsAlgorithmClass descriptions and pseudocodes:Begin    Declare a class sample1.       Declare a constructor of sample1.          Print “Construct an Object of sample1”       Declare a destructor of sample1.          Print ... Read More

Advertisements