Automatically Store Timestamp in MySQL Row

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

3K+ Views

Yes, you can achieve this in the following two ways.First Approach At the time of creation of a table.Second Approach At the time of writing query.The syntax is as follows.CREATE TABLE yourTableName ( yourDateTimeColumnName datetime default current_timestamp );You can use alter command.The syntax is as follows.ALTER TABLE yourTableName ADD yourColumnName datetime DEFAULT CURRENT_TIMESTAMP;Implement both the syntaxes now.The first approach is as follows.mysql> create table CurrentTimeStampDemo -> ( -> CreationDate datetime default current_timestamp -> ); Query OK, 0 rows affected (0.61 sec)If you do not pass any parameter for the column ‘CreationDate’, MySQL by default stores the current timestamp.Insert record in ... Read More

Load and Display an Image on iOS App Using Swift

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

1K+ Views

To load and display an image in iOS app we’ll first need to get an image.Then we’ll drag that image to our project and select copy if required option and our application target.Let’s see the rest with help of an example.Now, we’ll create an UIImageView and assign the image to its image property, for that we’ll create a function.func addImage(imageName img: String) {    let imageView = UIImageView()    imageView.frame = self.view.frame    imageView.contentMode = .scaleAspectFit    if let newImage = UIImage(named: img) {       imageView.image = newImage    }    self.view.addSubview(imageView) }Now, we’ll call this code in ... Read More

Order By Alphabet First Then Follow By Number in MySQL

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

969 Views

You need to use regular expression with ORDER BY clause. The syntax is as follows:SELECT *FROM yourTableName ORDER BY IF(yourColumnName RLIKE '^[a-z]', 1, 2), yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table AlphabetFirstThenNumberDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into AlphabetFirstThenNumberDemo(Name) values('John'); Query OK, 1 row affected (0.37 sec) mysql> insert ... Read More

Sample Questions for ITIL Foundation Course

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

238 Views

Information Technology Infrastructure Library (ITIL) is the framework that is designed to standardize the planning, selection, and delivery of IT services to a business. The goal of ITIL is to improve efficiency and also achieve predictable goals or targets. An ITIL enables an IT professional to be a business service partner, not just back-end support.ITIL Foundation ExaminationIt is a closed book examination.It consists of 40 questions.Each question has multiple choices.One mark is allotted for the correct answer.The duration of the exam is one hour.One has to score 65% of the marks to pass the examination i.e minimum 26 questions must ... Read More

Create JSON Format with GROUP_CONCAT in MySQL

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

1K+ Views

You can create JSON format using group_concat() function from MySQL. The syntax is as follows −SELECT yourColumnName1, GROUP_CONCAT(CONCAT('{anytName:"', yourColumnName, '", anyName:"', yourColunName, '"}')) anyVariableName from yourTableName group by yourColumnName1;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table JsonFormatDemo -> ( -> UserId int, -> UserName varchar(100), -> UserEmail varchar(100) -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert ... Read More

What is a Robonaut? Can it Replace Astronauts in the Future?

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

380 Views

Robonaut is a NASA robot, which is designed as a humanoid. The artificial intelligence makes it easier for Robonaut to do the same jobs as a human. Robonaut could help with anything from working on the International Space Station to exploring other worlds. The core idea behind the Robonaut series is to have a humanoid machine work alongside astronauts. Its form factor and dexterity are designed such that Robonaut can use space tools and work in similar environments suited to astronauts.These new space explorers won’t need space suits or oxygen to survive outside of the spacecraft. Thus they might help ... Read More

Non-Programmable 8-Bit I/O Port

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

708 Views

There are two types of Input Output ports. They are Programmable Input Output ports and Non-Programmable Input Output ports. Since the functions of Programmable Input Output ports changed by software they became more popular. We don't need to change the wiring rather the hardware of the I/O port to change the function. Intel 8255 is a popular Input Output chip based on port. Whereas the I/O ports which are non-programmable needs to change the wiring or the hardware to change its complete function. We will see in later that the connection needs to be changed when 8212 works like an ... Read More

Print Colors of Terminal in Python

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

766 Views

In the terminal, if you want to make some texts appears in colored mode, there are numerous ways in python programming to achieve it.Using python modules1.termcolor module: It is the ANSII Color formatting for output in the terminal.import sys from termcolor import colored, cprint text1 = colored('Hello, Tutorialspoint!', 'blue', attrs=['reverse', 'blink']) print(text1) cprint('Hello, Python!', 'blue', 'on_white') print_red_on_blue = lambda x: cprint(x, 'red', 'on_blue') print_red_on_blue('Hello, from Data Science!') print_red_on_blue('Hello, Python!') for i in range(10):    cprint(i, 'green', end=' ') cprint("Attention!", 'blue', attrs=['bold'], file=sys.stderr)ResultRead More

Delete Last Record on Condition from a Table in MySQL

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

9K+ Views

To delete last record (on condition) from a table, you need to use ORDER BY DESC with LIMIT 1. The syntax is as follows:DELETE FROM yourTableName WHERE yourColumnName1=yourValue ORDER BY yourColumnName2 DESC LIMIT 1;The above syntax will delete last record (on condition) from a table. It sorts the column in descending order and choose the first element to delete.To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table UserLoginTable    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> UserId int,    -> UserLoginDateTime datetime,    -> PRIMARY ... Read More

Add Grouping Specifiers for Large Numbers in Java

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

239 Views

For using the Formatter class, import the following package −import java.util.Formatter;We can group specifiers as shown below −Formatter f = new Formatter(); f.format("%,.2f", 38178.9889);The above sets thousands separator and 2 decimal places.The following is an example −Example Live Demoimport java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); f.format("%d", 50); System.out.println(f); f = new Formatter(); f.format("%,.2f", 38178.9889); System.out.println(f); } }Output50 38,178.99

Advertisements