George John has Published 1167 Articles

Get floor key from NavigableMap in Java

George John

George John

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

65 Views

To get floor key means to return the greatest key less than or equal to the given key, or null if there is no such key. This can be done with the floorKey() metho.The following is an example to get floor key from NavigableMapExample Live Demoimport java.util.*; public class Demo { ... Read More

MySQL date format DD/MM/YYYY select query?

George John

George John

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

3K+ Views

Format the date DD/MM/YYYY using select and order by in descending order. The syntax is as follows −SELECT *FROM yourTableName where yourDatetimeColumnName order by STR_TO_DATE(yourDatetimeColumnName, ’%d/%m%Y’) desc;The above syntax will give the date in descending order. To understand the above syntax, let us first create a table. The query to ... Read More

How to select max of mixed string/int column in MySQL?

George John

George John

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

222 Views

To select max of mixed string/int column, you need to use substring() function. The syntax is as follows:SELECT MAX(CAST(SUBSTRING(yourColumnName, 4, length(yourColumnName)-3) AS UNSIGNED)) 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 StringIntMixHighestDemo    -> ... Read More

How to select record from last 6 months in a news table using MySQL?

George John

George John

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

4K+ Views

To select the last 6 months records from news table, use the date_sub() function from MySQL since news records are arranged according to date.The syntax is as follows −select *from yourTableName where yourDateTimeColumnName >= date_sub(now(), interval 6 month);To understand the above concept, let us first create a NEWS table with ... Read More

How to cut only the first character in MySQL string?

George John

George John

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

3K+ Views

To cut only the first character, use the substr() function with UPDATE command. The syntax is as follows.UPDATE yourTableName set yourColumnName=substr(yourColumnName, 2);To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table CutStringDemo -> ( -> Value varchar(100) -> ... Read More

Connecting to MySQL database from the command line?

George John

George John

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

3K+ Views

To connect MySQL from the command line, firstly open command prompt. You can do this with the help of shortcut key “Windows + R”. On clicking, a panel will open and you need to type CMD and need to press OK button as shown below −After pressing the OK button, ... Read More

How to form a MySQL Conditional Insert?

George John

George John

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

2K+ Views

For this, you can insert using MySQL dual table. Let us create a table to understand the concept conditional insert. The query to create a table is as follows −mysql> create table ConditionalInsertDemo    -> (    -> UserId int,    -> TotalUser int,    -> NumberOfItems int    -> ... Read More

Why the G modifier in SELECT * FROM table_nameG?

George John

George John

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

122 Views

The \G modifier gets the result in vertical order. If you use \g modifier, then it won’t affect the result. The \g works likesemi-colon.Let us first create a table. The query to create a table is as follows:mysql> create table DemoOfVertical    -> (    -> Id int NOT NULL ... Read More

MySQL command for displaying current configuration variables?

George John

George John

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

1K+ Views

To display current configuration variables, you can use show command. The syntax is as follows −show variables;You can further rewrite the above syntax with LIKE operator. The syntax is as follows −show variables like ‘%anyStringValue%’;The query is as follows displaying an example to fetch some of the configuration variables −mysql> ... Read More

MySQL: selecting rows where a column is null?

George John

George John

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

2K+ Views

To select rows where a column is null, you can use IS NULL from MySQL with the help of where clause.The syntax is as follows −select *from yourTableName where yourColumnName IS NULL;Let us first create a table to understand the concept −mysql> create table NULLDemo1 -> ( ... Read More

Advertisements