Fetch Records from Specific Month and Year in MySQL Table

Smita Kapse
Updated on 30-Jul-2019 22:30:26

709 Views

Use YEAR() and MONTH() to display records from specific month and year respectively. Let us first create a table −mysql> create table DemoTable    (    CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    CustomerName varchar(20),    CustomerTotalBill int,    PurchasingDate date    ); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerName, CustomerTotalBill, PurchasingDate) values('John', 2000, '2019-01-21'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(CustomerName, CustomerTotalBill, PurchasingDate) values('Chris', 1000, '2019-01-31'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(CustomerName, CustomerTotalBill, PurchasingDate) values('Robert', ... Read More

Explain subn Methods of re Module in Python

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

2K+ Views

A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expressions are widely used in UNIX world. The re module in python refers to the module Regular Expressions (RE). It specifies a set of strings or patterns that matches it. Metacharacters are used to understand the analogy of RE. subn()method is similar to sub() and also returns the new string along with the no. of replacements.Syntaxre.subn (pattern, repl, string, count=0, flags=0)Exampleimport re print(re.subn('ov', '~*' , 'movie tickets booking in online')) t ... Read More

Left Align Components Vertically Using BoxLayout in Java

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

3K+ Views

To align components vertically, use the BoxLayout −JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));Now, create a Panel and add some buttons to it. After that set left alignment of components which are already arranged vertically using Component.LEFT_ALIGNMENT constant −JPanel panel = new JPanel(); JButton btn1 = new JButton("One"); JButton btn2 = new JButton("Two"); JButton btn3 = new JButton("Three"); JButton btn4 = new JButton("Four"); JButton btn5 = new JButton("Five"); panel.add(btn1); panel.add(btn2); panel.add(btn3); panel.add(btn4); panel.add(btn5); panel.setAlignmentX(Component.LEFT_ALIGNMENT);The following is an example to left align components vertically with BoxLayout −Examplepackage my; import java.awt.Component; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; ... Read More

Create Random Linear Extension for a DAG in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:26

182 Views

Here we will see how to create Random Linear Extension of a Directed Acyclic Graph (DAG). The Linear extension is basically the topological sorting of DAG. Let us consider the graph is like below −The topological sorting for a directed acyclic graph is the linear ordering of vertices. For every edge u-v of a directed graph, the vertex u will come before vertex v in the ordering.As we know that the source vertex will come after the destination vertex, so we need to use a stack to store previous elements. After completing all nodes, we can simply display them from ... Read More

Can I Overload Static Methods in Java

Narasimha Murthi
Updated on 30-Jul-2019 22:30:26

1K+ Views

Overloading is a one of the mechanisms to achieve polymorphism where, a class contains two methods with same name and different parameters.Whenever you call this method the method body will be bound with the method call based on the parameters.Example Live Demopublic class Calculator {    public int addition(int a , int b){       int result = a+b;       return result;    }    public int addition(int a , int b, int c){       int result = a+b+c;       return result;    }    public static void main(String args[]){       Calculator ... Read More

Select Rows Except First Row in Descending Order in MySQL

Kumar Varma
Updated on 30-Jul-2019 22:30:26

939 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Amount int    -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+--------+ | Amount ... Read More

HTML DOM Input Checkbox DefaultChecked Property

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

412 Views

The HTML DOM input checkbox defaultChecked property returns the default value of checked attribute of a checkbox in HTML.SyntaxFollowing is the syntax −object.defaultCheckedExampleLet us see an example of defaultChecked property − Live Demo HTML DOM checked property    body{       text-align:center;    }    p{       font-size:1.5rem;       color:#ff8741;    }    input{       width:30px;       height:30px;    }    button{       background-color:#db133a;       color:#fff;       padding:8px;       border:none;       width:180px;       margin:0.5rem;       ... Read More

HTML DOM Input Datetime Local Stepdown Method

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

92 Views

The HTML DOM Input DatetimeLocal stepdown() method defines the number of minutes the datetimeLocal field should decrease.SyntaxFollowing is the syntax −Calling stepDown method with a number, which by default is equal to 1inputDatetimeLocalObject.stepDown(number)ExampleLet us see an example of Input DatetimeLocal stepDown method − Live Demo Input DatetimeLocal stepDown()    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Datetime-Local-stepDown( ... Read More

KeyboardEvent.shiftKey Property in HTML DOM

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

125 Views

The HTML DOM KeyboardEvent shiftKey property returns the Boolean value (true/false) corresponding to if shift key was pressed using an event or not.SyntaxFollowing is the syntax −Returning booleanValue −event.shiftKeyExampleLet us see an example for KeyboardEvent shiftKey property − Live Demo KeyboardEvent shiftKey    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } KeyboardEvent-shiftKey Editor: I Dare you ... Read More

Generate Random Partition from Given Set in C++

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

310 Views

This is a C++ program to generate Random Partition out of a given set of numbers or characters.AlgorithmBegin    Take the integers or characters as input.    For choice 1:       Take the input of the n integer array.       Assign l = 0 to traverse the array.       Using rand(), generate random integer partition of n.       For each partition i, print next i integer from index value l.    For choice is 2:       Take the input of a string in ch[].       Calculate the length ... Read More

Advertisements