Decrement a Value in MySQL Keeping it Above Zero

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

5K+ Views

You can decrement value in MySQL with update command. With this, you can also restrict the value to not reach below 0.The syntax is as follows −update yourTableName set yourColumnName = yourColumnName - 1 where yourColumnName > 0;To avoid the value to go below zero, you can use yourColumnName > 0.To understand the above syntax, let us create a table. The query to create a table.mysql> create table DecrementDemo −> ( −> DecrementValue int −> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table with insert statement. ... Read More

Duties of Chief Minister in Indian Constitution

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

915 Views

The elected head of the government of the states in India is called as the Chief Minister of that particular state or union territory. The governor appoints the Chief Minister following elections to the state legislative assembly. The party with the majority of votes will elect their leader, the candidate for Chief Minister, who is invited by the governor to swear in as Chief Minister of State. The Chief Minister's term lasts for typically for 5 years, or until next General Elections. However, there is no limit for the number of terms he can serve.To be eligible for the post ... Read More

Find Maximum of Two 8-Bit Numbers in 8085

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

845 Views

In this program we will see how to find the maximum of two numbers.Problem StatementWrite 8085 Assembly language program to find the maximum number of two 8-bit number stored at location 8000H and 8001H.DiscussionThis checking is done by using the CMP instruction. This instruction is very similar to the SUB instruction. The only difference is that it does not update the value of Accumulator after executing. So after comparing, if the CY flag is set, it means that the first number is smaller, and the second one is largerInputFirst inputAddressData......8000FD800123......second inputAddressData......800059800175......Flow DiagramProgramAddressHEX CodesLabelMnemonicsCommentsF00021, 00, 80LXI H, 8000HPoint to the first ... Read More

Detect if an iOS Application is in Background or Foreground

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

3K+ Views

To detect if an iOS application is in background or foreground we can simply use the UIApplication just like we can use it to detect many other things like battery state, status etc.Let’s see how we can do this in our application. We’ll make use of shared resources of our Application which are stored in UIApplication.shared. We can use it like shown below −print(UIApplication.shared.applicationState)The shared.application state is an enum of type State, which consists of the following as per apple documentation.public enum State : Int {    case active    case inactive    case background }The case active means that ... Read More

MySQL Date Column Auto Fill with Current Date

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

16K+ Views

You can use now() with default auto fill and current date and time for this. Later, you can extract the date part using date() function.Case 1:The syntax is as follows:yourDateColumnName date default ‘yourDateValue’;Case 2:The syntax is as follows:yourDateColumnName datetime default now();To understand the above, let us create a table. The query to create a table is as follows:mysql> create table DefaultCurrentdateDemo    -> (    -> LoginDate datetime default now()    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into DefaultCurrentdateDemo values(); Query OK, 1 ... Read More

Demonstrating Variable Length Arguments in Java

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

4K+ Views

A method with variable length arguments(Varargs) in Java can have zero or multiple arguments. Variable length arguments are most useful when the number of arguments to be passed to the method is not known beforehand. They also reduce the code as overloaded methods are not required.A program that demonstrates this is given as follows:Example Live Demopublic class Demo {    public static void Varargs(String... str) {       System.out.println("Number of arguments are: " + str.length);       System.out.println("The argument values are: ");       for (String s : str)          System.out.println(s);    } ... Read More

Get Record of a Specific Year from Timestamp in MySQL

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

318 Views

You can get year out of timestamp using YEAR() function. The syntax is as follows −SELECT yourColumnName FROM yourTableName WHERE YEAR(yourTimestampColumnName)='yourYearValue’';To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table getYearOut    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(10),    -> yourTimestamp timestamp default current_timestamp,    -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.56 sec)Insert some records in the table using INSERT command−mysql> insert into getYearOut(Name, yourTimestamp) values('John', now()); Query OK, 1 row affected (0.26 sec) ... Read More

Difference Between Story and Screenplay in Film Scripts

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

4K+ Views

What is a Script All About?Although based on the same incident, both story and screenplay still have disparities. A script is a written text generally created for a film, play, TV serial, etc. Only a script provides a very elaborated explanation of the incidents and characters. A script is created for both movies based on a story. Therefore, we can consider the story as an account of real and imaginary events. A script also gives an opportunity to the actor to comprehend the nature of the character, personality, likes and dislikes. Moreover, as per the demand scriptwriters write their script ... Read More

Retrieve the First Entry in a TreeMap in Java

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

2K+ Views

Use the firstEntry() method in TreeMap to retrieve the first entry.Create a TreeMap and add some elementsTreeMap m = new TreeMap(); m.put(1, "India"); m.put(2, "US"); m.put(3, "Australia"); m.put(4, "Netherlands"); m.put(5, "Canada");Now, retrieve the first entrym.firstEntry()The following is an example to retrieve first entry in the TreeMapExample Live Demoimport java.util.*; public class Demo {    public static void main(String args[]){       TreeMap m = new TreeMap();       m.put(1, "India");       m.put(2, "US");       m.put(3, "Australia"); m.put(4, "Netherlands"); m.put(5, "Canada"); ... Read More

Detect When AVPlayer Video Ends Playing in Swift

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

2K+ Views

To detect the end of a video in swift we’ll need to create a video player, then use notifications to detect when the video stops playing. We’ll do this with help of an example in swift.Let’s create a project and drag and drop any video with extension “mp4”, select copy resource if required and add to the target of our project.Now we’ll programmatically first create a Video Player, then we’ll create url of the video in our project, and then we’ll play the video.var videoPlayer: AVPlayer!Now, in the viewDidAppear add the following code.override func viewDidAppear(_ animated: Bool) {    super.viewDidAppear(animated) ... Read More

Advertisements