Nishtha Thakur

Nishtha Thakur

398 Articles Published

Articles by Nishtha Thakur

Page 21 of 40

How can we force MySQL out of TRADITIONAL mode?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jan-2020 152 Views

With the help of the following command we can force MySQL out of TRADITIONAL mode −mysql> Set SQL_MODE =''; Query OK, 0 rows affected (0.00 sec)

Read More

What MySQL returns if specified format string is not as per accordance with the date string passed as arguments to STR_TO_DATE() function?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jan-2020 585 Views

If the specified format string and date string did not match then MySQL will return NULL value as output along with a warning. Following is an example to understand the same −mysql> Select STR_TO_DATE('20172810', '%Y, %d%m'); +------------------------------------+ | STR_TO_DATE('20172810', '%Y, %d%m') | +------------------------------------+ | NULL                               | +------------------------------------+ 1 row in set, 1 warning (0.00 sec)The query above returns NULL as output because the format string is having a comma (, ) after %Y but date string is not having any comma after 2017.mysql> Show Warnings\G ...

Read More

How can it be possible to add 3 months interval in a MySQL date without using the word 'Months' with interval?

Nishtha Thakur
Nishtha Thakur
Updated on 29-Jan-2020 453 Views

It is possible with the help of keyword Quarter as follows −mysql> Select '2017-06-20' + INTERVAL 1 Quarter AS 'After 3 Months Interval'; +-------------------------+ | After 3 Months Interval | +-------------------------+ | 2017-09-20 | +-------------------------+ 1 row in set (0.00 sec)

Read More

Preserve select order within MySQL UNION?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 348 Views

It’s a good choice to use CASE statement. Do not use UNION. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ShippingDate datetime    ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ShippingDate) values('2019-04-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ShippingDate) values('2019-01-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(ShippingDate) values('2019-05-11'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(ShippingDate) values('2018-12-31'); Query OK, 1 row ...

Read More

C++ Program to Perform integer Partition for a Specific Case

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 202 Views

This is a C++ program to perform integer partition for a specific case. In this program, a positive integer n is given, and shall have to generate all possible unique ways to represent n as sum of positive integers.AlgorithmBegin    function displayAllUniqueParts(int m):    1) Set Index of last element k in a partition to 0    2) Initialize first partition as number itself, p[k]=m    3) Create a while loop which first prints current partition, then generates next partition. The loop stops    when the current partition has all 1s.    4) Display current partition as displayArray(p, k + ...

Read More

How to search by specific pattern in MySQL?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 187 Views

You can use regular expression for this. Let us first create a table −mysql> create table DemoTable    (    UserId varchar(100)    ); Query OK, 0 rows affected (1.28 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('User-123-G'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Us-453-GO'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('TRUE-908-K'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+------------+ | UserId     | ...

Read More

How to center align component using BoxLayout with Java?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 7K+ Views

Let us first create a panel and set some buttons −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);Now, use the setAlignmentX() and within that specify alignment to the center of the component −panel.setAlignmentX(Component.CENTER_ALIGNMENT);The following is an example to center align component using 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; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       ...

Read More

MySQL Select displaying Data type in a separate column?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 161 Views

You can use INFORMATION_SCHEMA.COLUMNS for this. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(20)    ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable(Name) values('Robert'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable(Name) values('Sam'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following ...

Read More

Distribute extra horizontal and vertical space in a GridBagLayout with Java

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 899 Views

To distribute the extra horizontal and vertical space, use the fields weightx and weighty. The following is an example to distribute extra horizontal and vertical space −Examplepackage my; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Demo Frame");       JPanel panel = new JPanel();       GridBagLayout layout = new GridBagLayout();       panel.setLayout(layout);       GridBagConstraints gbc = new GridBagConstraints();       JLabel label = new JLabel("Rank: ");   ...

Read More

C++ Program to Find Whether a Path Exists Between 2 Given Nodes

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 350 Views

This is a C++ program to find whether a path exists between 2 given nodesAlgorithmBegin    function isReach() is a recursive function to check whether d is reachable to s:    A) Mark all the vertices as unvisited.    B) Mark the current node as visited and enqueue it and it will be used to get all adjacent vertices of a vertex.    C) Dequeue a vertex from queue and print it.    D) Get all adjacent vertices of the dequeued vertex s.    E) If an adjacent has not been visited, then mark it visited and enqueue it.   ...

Read More
Showing 201–210 of 398 articles
« Prev 1 19 20 21 22 23 40 Next »
Advertisements