Samual Sam has Published 2492 Articles

How to sort time in AM/ PM in MySQL?

Samual Sam

Samual Sam

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

2K+ Views

To sort time in AM/PM in MySQL, you can use ORDER BY STR_TO_DATE(). Following is the syntax −select yourColumnName from yourTableName ORDER BY STR_TO_DATE(yourColumnName , '%l:%i %p');Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserLogoutTime varchar(200) ); Query OK, ... Read More

How to know the exact number of table and columns in a MySQL database?

Samual Sam

Samual Sam

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

197 Views

To get the exact number if table and columns in a MySQL database, use the DISTINCT inside COUNT().Let’s say we have a database ‘sample’ and we need to work on it to get the exact number of table and columns.To achieve it, the query is as follows −mysql> SELECT COUNT(DISTINCT ... Read More

LocalTime plusMinutes() method in Java

Samual Sam

Samual Sam

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

38 Views

An immutable copy of a LocalTime object where some minutes are added to it can be obtained using the plusMinutes() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of minutes to be added and it returns the LocalTime object with the added ... Read More

C++ Program to Implement Hash Tables with Double Hashing

Samual Sam

Samual Sam

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

3K+ Views

A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.Double hashing is a collision resolving technique in Open Addressed Hash tables. Double hashing ... Read More

Java Program to remove key value pair from HashMap?

Samual Sam

Samual Sam

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

230 Views

Let’s say the following is our HashMap −HashMapmap = new HashMap();Add key value pair to the HashMap −map.put("1", "A"); map.put("2", "B"); map.put("3", "C"); map.put("4", "D"); map.put("5", "E"); map.put("6", "F"); map.put("7", "G"); map.put("8", "H"); map.put("9", "I");Now, use the remove() method to remove the key-value pair −map.remove("5");Example Live Demoimport java.util.Collection; import java.util.HashMap; import ... Read More

How to check if data is NULL in MySQL?

Samual Sam

Samual Sam

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

332 Views

You can use IF() to check if data is NULL.  Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(200),    Age int ); Query OK, 0 rows affected (0.44 sec)Insert records in the table using insert command −mysql> ... Read More

C++ Program to Implement Hash Tables with Linear Probing

Samual Sam

Samual Sam

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

8K+ Views

A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.Linear probing is a collision resolving technique in Open Addressed Hash tables. In this ... Read More

Java Program to write an array of strings to a file

Samual Sam

Samual Sam

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

1K+ Views

Here’s our file −FileWriter writer = new FileWriter("E:/demo.txt");Now, consider a string array −String arr[] = { "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE" };Write the above array to the file “demo.txt” −int len = arr.length; for (int i = 0; i < len; i++) {    writer.write(arr[i] + ... Read More

MySQL query to perform delete operation where id is the biggest?

Samual Sam

Samual Sam

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

140 Views

You can use ORDER BY DESC command with LIMIT 1 for this since we need to delete only a single ID.Let us first create a table −mysql> create table DemoTable (    UserId int,    UserName varchar(20) ); Query OK, 0 rows affected (0.57 sec)Insert records in the table using ... Read More

Can we add a column to a table from another table in MySQL?

Samual Sam

Samual Sam

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

2K+ Views

Yes, we can add a column to a table from another table. Let us first create two tables. The query to create a table is as follows −mysql> create table FirstTable    -> (    -> UserId int,    -> UserName varchar(20)    -> ); Query OK, 0 rows ... Read More

Advertisements