karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 98 of 143

How can I use IFNULL() function at the place of COALESCE() function in MySQL?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 2K+ Views

As we know that IFNULL() function will return the first argument if it is not NULL otherwise it returns the second argument. On the other hand, COALESCE() function will return first non-NULL argument. Actually, both IFNULL() and COALESCE() functions in MySQL works equivalently if the number of arguments is two only. The reason behind this is that IFNULL() function accepts only two arguments and in contrast, COALESCSE() function can accept any number of arguments.Suppose if we want to use IFNULL() function at the place of COALESCE() function then the number of arguments must be two. Following example will demonstrate it ...

Read More

What MySQL ELT() function returns if the index number, provided as an argument, is higher than the number of strings?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 158 Views

MySQL ELT() function returns NULL as output if the index number provided as argument is higher than the number of strings. Following is an example to make it clearer −Examplemysql> Select ELT(6,'Ram','is','a','good','boy')As Result; +--------+ | Result | +--------+ | NULL   | +--------+ 1 row in set (0.00 sec)As we can see that index number is 6 and the list of strings is having only 5 strings. Hence MySQL returns NULL.

Read More

Tokenize text using NLTK in python

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 919 Views

Given a character sequence and a defined document unit, tokenization is the task of chopping it up into pieces, called tokens, perhaps at the same time throwing away certain characters, such as punctuation. In the context of nltk and python, it is simply the process of putting each token in a list so that instead of iterating over each letter at a time, we can iterate over a token.For example, given the input string −Hi man, how have you been?We should get the output −['Hi', 'man', ', ', 'how', 'have', 'you', 'been', '?']We can tokenize this text using the word_tokenize ...

Read More

Python Regex to extract maximum numeric value from a string

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 511 Views

The easiest way to extract the maximum numeric value from a string using regex is to −Use the regex module to extract all the numbers from a stringFind the max from these numbersFor example, for the input string −There are 121005 people in this city, 1587469 in the neighboring city and 18775994 in a far-off city.We should get the output −18775994We can use "\d+" regex to find all numbers in a string as \d signifies a digit and the plus sign finds the longest string of continuous digits. We can implement it using the re package as follows −import re ...

Read More

What MySQL returns if sub-query, used to assign new values in the SET clause of UPDATE statement, returns multiple rows?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 323 Views

In this case, MySQL will return an error message because we know that if sub-query is used to assign new values in the SET clause of UPDATE statement then it must return exactly one row for each row in the update table that matches the WHERE clause.Examplemysql> insert into info(id, remarks) values(5, 'average'); Query OK, 1 row affected (0.06 sec) mysql> select * from info; +------+-----------+ | id   | remarks   | +------+-----------+ | 1    | Good      | | 2    | Good      | | 3    | Excellent | | 4   ...

Read More

How can we sort MySQL output in ascending order?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 354 Views

We need to specify ASC (short form for ASCENDING) keyword in ORDER BY clause if we want to sort out the result set in ascending order.SyntaxSelect column1, column2,…,columN From table_name ORDER BY column1[column2,…] ASC;ExampleIn the following example, we have sorted the result set by column ‘Name’ in the ascending order.mysql> Select * from Student ORDER BY Name ASC; +------+---------+---------+-----------+ | Id   | Name    | Address | Subject   | +------+---------+---------+-----------+ | 2    | Aarav   | Mumbai  | History   | | 1    | Gaurav  | Delhi   | Computers | | 15   | Harshit | Delhi   | Commerce  | | 17   | Raman   | Shimla  | Computers | +------+---------+---------+-----------+ 4 rows in set (0.00 sec)

Read More

Database operations in Java

karthikeya Boyini
karthikeya Boyini
Updated on 19-Jun-2020 2K+ Views

This article provides an example of how to create a simple JDBC application. This will show you how to open a database connection, execute a SQL query, and display the results.Creating JDBC ApplicationThere are following six steps involved in building a JDBC application −Import the packages: Requires that you include the packages containing the JDBC classes needed for database programming. Most often, using import java.sql.* will suffice.Register the JDBC driver: Requires that you initialize a driver so you can open a communication channel with the database.Open a connection: Requires using the DriverManager.getConnection() method to create a Connection object, which represents ...

Read More

Counting number of paragraphs in text file using java

karthikeya Boyini
karthikeya Boyini
Updated on 19-Jun-2020 706 Views

We can read paragraphs in a file by reading it in a string and then spilting based on "\r" pattern. See the example below −ExampleConsider the following text file in the classpath.test.txtThis is Line 1 This is Line 2 This is Line 3 This is Line 4 This is Line 5 This is Line 6 This is Line 7 This is Line 8 This is Line 9 This is Line 10Tester.javaimport java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Tester {    public static void main(String args[]) throws IOException {       FileUtil fileUtil = ...

Read More

Counting number of characters in text file using java

karthikeya Boyini
karthikeya Boyini
Updated on 19-Jun-2020 6K+ Views

We can read characters in a file using BufferedReader class of Java. See the example below −ExampleConsider the following text file in the classpath.test.txtThis is Line 1 This is Line 2 This is Line 3 This is Line 4 This is Line 5 This is Line 6 This is Line 7 This is Line 8 This is Line 9 This is Line 10Tester.javaimport java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; public class Tester {    private static final String FILE_PATH = "data.txt";    public static void main(String args[]) throws IOException {       ...

Read More

Create Toast Message in Java Swing

karthikeya Boyini
karthikeya Boyini
Updated on 19-Jun-2020 2K+ Views

A toast message is an alert which disappears with time automatically. With JDK 7, we can create a toast message similar to an alert on android very easily. Following are the steps needed to make a toast message.Make a rounded rectangle shaped frame. Add a component listener to frame and override the componentResized() to change the shape of the frame. This method recalculates the shape of the frame correctly whenever the window size is changed.frame.addComponentListener(new ComponentAdapter() {    @Override    public void componentResized(ComponentEvent e) {       frame.setShape(new  RoundRectangle2D.Double(0, 0, frame.getWidth(),       frame.getHeight(), 20, 20));    } ...

Read More
Showing 971–980 of 1,421 articles
« Prev 1 96 97 98 99 100 143 Next »
Advertisements