AmitDiwan has Published 10740 Articles

Get only the date from datetime in MySQL?

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 06:49:22

2K+ Views

To get only the date from DateTime, use the date format specifiers −%d for day %m for month %Y for yearLet us first create a table −mysql> create table DemoTable (    AdmissionDate datetime ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command ... Read More

Replace only a specific value from a column in MySQL

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 06:47:28

10K+ Views

To replace, use the REPLACE() MySQL function. Since you need to update the table for this, use the UPDATE() function with the SET clause.Following is the syntax −update yourTableName set yourColumnName=replace(yourColumnName, yourOldValue, yourNewValue);Let us first create a table −mysql> create table DemoTable (    FirstName varchar(100),    CountryName varchar(100) ); ... Read More

MySQL query to place a specific record on the top

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 06:44:35

199 Views

For this, you can use the ORDER BY CASE statement. Let us first create a table −mysql> create table DemoTable (    StudentName varchar(100),    StudentMarks int ); Query OK, 0 rows affected (0.97 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 45); Query ... Read More

MySQL query to order by the first number in a set of numbers?

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 06:41:39

265 Views

To order by the first number in a set of numbers, use ORDER BY SUBSTRING_INDEX(). Let us first create a table −mysql> create table DemoTable (    SetOfNumbers text ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('245, ... Read More

Can we use reserved word ‘index’ as MySQL column name?

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 06:39:27

719 Views

Yes, but you need to add a backtick symbol to the reserved word (index) to avoid error while using it as a column name.Let us first create a table −mysql> create table DemoTable (    `index` int ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table ... Read More

Getting maximum from a column value and set it for all other values in the same column with MySQL?

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 06:31:40

117 Views

Let us first create a table −mysql> create table DemoTable (    FirstName varchar(100),    Score int ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('David', 59); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable ... Read More

Compare for NULL value and display value 1 for these values in a new MySQL column?

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 06:29:11

102 Views

For this, use IF() along with IS NULL property. Let us first create a table −mysql> create table DemoTable (    Name varchar(100),    CountryName varchar(100) ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 'US'); Query OK, ... Read More

EnumMap class in Java

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 13:27:04

214 Views

The java.util.EnumMap class is a specialized Map implementation for use with enum keys. Following are the important points about EnumMap −All of the keys in an enum map must come from a single enum type that is specified, explicitly or implicitly, when the map is created.Enum maps are maintained in the natural ... Read More

Compare two Strings in Java

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 13:23:44

432 Views

Compare two strings using compareTo() method in Java. The syntax is as follows −int compareTo(Object o)Here, o is the object to be compared.The return value is 0 if the argument is a string lexicographically equal to this string; a value less than 0 if the argument is a string lexicographically ... Read More

HTML KeyboardEvent which Property

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 12:00:14

109 Views

The HTML KeyboardEvent which property returns the Unicode character code of the key that fires the onkeypress event, onkeydown event or onkeyup event in an HTML document.SyntaxFollowing is the syntax −event.whichLet us see an example of HTML KeyboardEvent which property −Example Live Demo    body {       ... Read More

Advertisements