Ayyan

Ayyan

30 Articles Published

Articles by Ayyan

Page 2 of 3

What happens if the argument ‘count’ in MySQL SUBSTRING_INDEX() function has the value greater than the total number of occurrences of delimiter?

Ayyan
Ayyan
Updated on 22-Jun-2020 225 Views

MySQL SUBSTRING_INDEX() function will return the same string as output if the argument ‘count’ has the value greater than the total number of occurrences of delimiter. It can be demonstrated with the following example −mysql> Select SUBSTRING_INDEX('My Name is Ram','a',3); +-----------------------------------------+ | SUBSTRING_INDEX('My Name is Ram','a',3) | +-----------------------------------------+ | My Name is Ram                          | +-----------------------------------------+ 1 row in set (0.00 sec)The above query returns the same string because 3 is greater than the total number of occurrences of delimiter provided as argument i.e. ‘a’. There are only two ‘a’ in the string.

Read More

How can we calculate the Date in MySQL using functions?

Ayyan
Ayyan
Updated on 20-Jun-2020 223 Views

In MySQL, we can use the following functions to calculate the Date −CURDATE() Function − Basically it returns the current date of the computer.YEAR() Function − It returns the year of the specified date.MONTH() function − It returns the month of the specified date.DAY() Function − It returns the day of the specified date.RIGHT() Function − It returns the number of character as specified within the function from the given date. The part of the expression that compares the returns from RIGHT() function evaluates 1 or 0.To understand it, consider the data, as follows, from a table named ‘Collegedetail’ −mysql> ...

Read More

Which MySQL function is used to find first non-NULL value from a list of values?

Ayyan
Ayyan
Updated on 20-Jun-2020 289 Views

We can use MySQL COALESCE() function to get the first non-NULL value as output from a list of values. In other words, this function will check all the values until non-null value found. It can take one or more than one argument. It is having the following syntax:COALESCE(value1, value2, …, valueN)ExampleFollowing is an example to demonstrate it −mysql> Select COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL); +--------------------------------------------------+ | COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL) | +--------------------------------------------------+ | Ram                                              | +--------------------------------------------------+ 1 row in set (0.00 sec)

Read More

What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?

Ayyan
Ayyan
Updated on 20-Jun-2020 183 Views

NULL as both argumentsMySQL returns blank output if we will use NULL as both of the arguments in CONCAT_WS() function.Examplemysql> Select CONCAT_WS('', NULL, NULL); +-------------------------+ | CONCAT_WS('', NULL, NULL) | +-------------------------+ |                         | +-------------------------+ 1 row in set (0.00 sec)NULL as one of the argumentMySQL returns the value of the other argument as output if we will use NULL as one of the argument in CONCAT_WS() function.Examplemysql> Select CONCAT_WS('', NULL, 'Delhi'); +----------------------------+ | CONCAT_WS('', NULL, 'Delhi') | +----------------------------+ | Delhi                 ...

Read More

How can we fetch a particular row as output from a MySQL table?

Ayyan
Ayyan
Updated on 20-Jun-2020 4K+ Views

For fetching a particular row as output, we need to use WHERE clause in the SELECT statement. It is because MySQL returns the row based on the condition parameter given by us after WHERE clause.ExampleSuppose we want to fetch a row which contains the name ‘Aarav’ from student table then it can be done with the help of the following query −mysql> Select * from Student WHERE Name = 'Aarav'; +------+-------+---------+---------+ | Id   | Name  | Address | Subject | +------+-------+---------+---------+ | 2    | Aarav | Mumbai  | History | +------+-------+---------+---------+ 1 row in set (0.00 sec)

Read More

How to convert a Boolean to Integer in JavaScript?

Ayyan
Ayyan
Updated on 15-Jun-2020 459 Views

Yes, it is possible to convert Boolean to Integer in JavaScript, using the Ternary Operator. Example You can try to run the following code to convert Boolean to Integer −           JavaScript Boolean                          var answer = true;           document.write(answer);           var pass_marks = answer ? 90 : 40;           document.write("Passing Marks: "+pass_marks);           

Read More

What are async generator methods in JavaScript?

Ayyan
Ayyan
Updated on 12-Jun-2020 251 Views

Async generator functions are the same like generator function. The async generator functions will return an object, whereas an async generator whose methods such as next, throw and return promises for { value, done }, instead returning directly.ExampleHere’s an example from GitHub showing function returning async generator object −async function* readLines(path) {    let file = await fileOpen(path);       try {          while (!file.EOF) {             yield await file.readLine();          }       } finally {       await file.close();    } }

Read More

Is it a good practice to place all declarations at the top in JavaScript?

Ayyan
Ayyan
Updated on 20-May-2020 158 Views

Yes, it is a good practice to place all the JavaScript declarations at the top. Let’s see an example −Example           JavaScript String match() Method                        // all the variables declared at top          var str, re, found;                    str = "For more information, see Chapter 3.4.5.1";          re = /(chapter \d+(\.\d)*)/i;          found = str.match( re );          document.write(found );           The following are the valid reasons −Gives a single place to check for all the variables.Helps in avoiding global variablesRe-declarations are avoided.The code is easy to read for others as well.

Read More

How to write "Hello World" Program in C++?

Ayyan
Ayyan
Updated on 26-Feb-2020 1K+ Views

To run the hello world program, you'll have to follow the following steps −Write a C++ programNow that you have a compiler installed, its time to write a C++ program. Let's start with the epitome of programming example's, it, the Hello world program. We'll print hello world to the screen using C++ in this example. Create a new file called hello.cpp and write the following code to it −#include int main() {    std::cout

Read More

What is the Java Runtime Environment (JRE)?

Ayyan
Ayyan
Updated on 25-Feb-2020 631 Views

JRE is Java Runtime Environment and is the machine-specific implementation of JVM. It contains libraries like rt.jar, class loaders etc which are used by JVM.

Read More
Showing 11–20 of 30 articles
Advertisements