Jennifer Nicholas has Published 332 Articles

Insert current date in datetime format MySQL?

Jennifer Nicholas

Jennifer Nicholas

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

737 Views

To insert the current date (not time), then you can use in-built function CURDATE() from MySQL. The syntax is as follows −INSERT INTO yourTableName values(curdate());Or if you want to add date and time both then you can use the in-built function NOW() from MySQL. The syntax is as follows −INSERT ... Read More

Concatenate two columns in MySQL?

Jennifer Nicholas

Jennifer Nicholas

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

7K+ Views

To concatenate two columns, use CONCAT() function in MySQL. The syntax is as follows −select CONCAT(yourColumnName1, ' ', yourColumnName2) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table concatenateTwoColumnsDemo    −> (    −> ... Read More

How to bulk update MySQL data with a single query?

Jennifer Nicholas

Jennifer Nicholas

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

5K+ Views

You can bulk update MySQL data with one query using CASE command. The syntax is as follows −update yourTableName set yourUpdateColumnName = ( Case yourConditionColumnName WHEN Value1 THEN ‘’UpdatedValue’ WHEN Value2 THEN ‘UpdatedValue’ . . N END) where yourConditionColumnName IN(Value1, Value2, .....N);To understand the above concept, let us create a ... Read More

MySQL syntax not evaluating with not equal operator in presence of null?

Jennifer Nicholas

Jennifer Nicholas

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

108 Views

Use the IS NOT NULL operator to compare with NULL values. The syntax is as follows −SELECT *FROM yourTableName where yourColumnName1 is not null or yourColumnName2 anyIntegerValue;To check the not equal to in presence of null, let us create a table. The query to create a table is as ... Read More

Can we update MySQL with if condition?

Jennifer Nicholas

Jennifer Nicholas

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

285 Views

You can update MySQL with IF condition as well as CASE statement. For this purpose, let us first create a table. The query to create a table −mysql> create table UpdateWithIfCondition    −> (    −> BookId int,    −> BookName varchar(200)    −> ); Query OK, 0 rows affected ... Read More

How to get the Average on MySQL time column?

Jennifer Nicholas

Jennifer Nicholas

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

1K+ Views

To get average on time column, use the below syntax. It will give the average in time format −SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(yourColumnName))) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The following is the query −mysql> create table AverageOnTime    −> (    −> PunchInTime time   ... Read More

Increase and decrease row value by 1 in MySQL with Stored Procedure?

Jennifer Nicholas

Jennifer Nicholas

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

534 Views

Let us first create a table to increase and adecrease row value by 1. The following is the query −mysql> create table IncrementAndDecrementValue    −> (    −> UserId int,    −> UserScores int    −> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using ... Read More

MySQL difference between two timestamps in Seconds?

Jennifer Nicholas

Jennifer Nicholas

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

175 Views

You can use in-built function UNIX_TIMESTAMP() from MySQL to get the timestamps and the difference between two timestamps. The syntax is as follows −SELECT UNIX_TIMESTAMP(yourColumnName1) - UNIX_TIMESTAMP(yourColumnName2) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The following is the query to create a table −mysql> ... Read More

HTML5 geolocation 'permission denied' error in Mobile Safari

Jennifer Nicholas

Jennifer Nicholas

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

328 Views

Whenever a mobile website is created and there is a requirement in which user is requested for current position on button click, then HTML5 geolocation is used.This is working fine in mobile chrome.However when in Mobile Safari, the user is prompted to share location and browser defaults to geolocation then ... Read More

What is meant by HTML5 Web Messaging?

Jennifer Nicholas

Jennifer Nicholas

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

79 Views

Web Messaging is the way for documents to separates browsing context to share the data without Dom. It overrides the cross-domain communication problem in different domains, protocols or ports.For example, you want to send the data from your page to ad container, which is placed at iframe, or voice-versa, in ... Read More

Advertisements