Group By and Display Only Non-Empty Column Values in MySQL

Rama Giri
Updated on 30-Jul-2019 22:30:26

1K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id varchar(100),    -> Message varchar(200)    -> ); Query OK, 0 rows affected (1.17 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('1', ''); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('1', 'Hi'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('2', 'Hello'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('3', 'Awesome'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('3', ... Read More

Show Alert Dialog in iOS

Rama Giri
Updated on 30-Jul-2019 22:30:26

2K+ Views

Knowing how to play with Alert is very important if you’re designing any iOS Application. Here we will be focusing on how to show Alert using UIAlertController.To read more about UIAlertController refer −  https://developer.apple.com/documentation/uikit/uialertcontrollerIn this, we will be creating a new project where we will have a button, on tapping that button we will show alert with custom message.Step 1 − Open Xcode → New Projecr → Single View Application → Let’s name it “Alert”Step 2 − Open Main.storyboard and add a button and name it tap. Create @IBAction of that button in ViewController.swit and name the same as tap.There’s ... Read More

HTML DOM Input Datetime Min Property

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

167 Views

The HTML DOM Input Datetime min property returns/sets min attribute of Input Datetime.SyntaxFollowing is the syntax −Returning string valueinputDatetimeObject.minSet min to string valueinputDatetimeObject.min = YYYY-MM-DDThh:mm:ssTZDString ValuesHere, “YYYY-MM-DDThh:mm:ssTZD” can be the following −stringValueDetailsYYYYIt defines year (eg:1998)MMIt defines month (eg: 05 for May)DDIt defines Day (eg: 24)TIt is a separator for date and timehhIt defines hour (eg:12)mmIt defines minutes (eg:48)ssIt defines seconds (eg:00)TZDTime Zone Designator (IST denotes Indian Standard Time)ExampleLet us see an example of Input Datetime min property − Live Demo Input Datetime Min Date & Time: Decrease min age bar    var ... Read More

Use of Static Variable in Swift

Mohtashim M
Updated on 30-Jul-2019 22:30:26

8K+ Views

Before we see where and how to use static variable, let us first understand, What is static variable in swift?Static VariableStatic variables are those variables whose values are shared among all the instance or object of a class. When we define any variable as static, it gets attached to a class rather than an object. The memory for the static variable will be allocation during the class loading time.Let us understand above figure, we have a class Sample and it has two object s1 and s2. You see s1 and s2 both have their variable “a” separately but they have ... Read More

Order By Date Ascending in MySQL

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

394 Views

You can use STR_TO_DATE() function. Let us first create a table −mysql> create table DemoTable    (    AdmissionDate varchar(200)    ); Query OK, 0 rows affected (1.19 sec)Insert records in the table using insert command −mysql> insert into DemoTable values('12-01-2019'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('14-12-2016'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('26-04-2018'); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable values('31-05-2013'); Query OK, 1 row affected (0.30 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the ... Read More

Get Max Tables in Select Using DatabaseMetadata in Java

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

82 Views

The getMaxTablesInSelect() method of the DatabaseMetaData interface is used to find out the maximum number of tables that the underlying database allows in an SQL SELECT statement.This method returns an integer value, representing the maximum number of tables allowed in a SELECT statement. If this value is 0 it indicates that there is no limit or, limit is unknown.To get the DatabaseMetaData object −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.Get the connection object using the getConnection() method ... Read More

Fetch Data Between Two Rows in MySQL

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

466 Views

To fetch data between two rows, use the concept of LIMIT. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(10)    ); Query OK, 0 rows affected (0.22 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('Larry'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(Name) values('Robert'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected ... Read More

Need and Usage of Copy Constructor in Java

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

510 Views

A copy constructor is a parameterized constructor and it can be used when we want to copy the values of one object to another.Example:class Employee {    int id;    String name;    Employee(int id, String name)    {       this.id = id;       this.name = name;    }    Employee(Employee e)    {       id = e.id;       name = e.name;    }    void show()    {       System.out.println(id + " " + name);    }    public static void main(String args[])    {       ... Read More

Disable Horizontal Scrollbar in Java

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

1K+ Views

To disable only the horizontal scrollbar in Java, use the JScrollPane.HORIZONTAL_SCROLLBAR_NEVER. Let’s say you created a Box with some button components. Now, create a JScrollPane −JScrollPane scrollPane = new JScrollPane();Set the Viewport view as Box −scrollPane.setViewportView(box);Now, disable the horizontal scrollbar −scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);The following is an example to disable only the horizontal scrollbar −Examplepackage my; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Demo");       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JButton button1 = new JButton("Tutorials");       JButton ... Read More

Can a Constructor Throw an Exception in Java

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

6K+ Views

Yes, constructors are allowed to throw an exception in Java.A Constructor is a special type of a method that is used to initialize the object and it is used to create an object of a class using the new keyword, where an object is also known as an Instance of a class. Each object of a class will have its own state (Instance variables) and access to methods of its class.Throw an Exception from a ConstructorA checked exception can be used to indicate a legitimate problem when trying to create an instance, while an unchecked exception typically indicates a bug either in the ... Read More

Advertisements