Lakshmi Srinivas has Published 315 Articles

When MySQL SUBSTRING_INDEX() function returns the same string, provided in the argument, as output?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 20-Jun-2020 11:30:02

114 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('www.google.co.in', '.', 4); +-------------------------------------------+ | SUBSTRING_INDEX('www.google.co.in', '.', 4) | +-------------------------------------------+ | www.google.co.in     ... Read More

How Are MySQL INSTR() and LIKE operator similar?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 20-Jun-2020 10:54:47

418 Views

We can use both INSTR() function and LIKE operator to search or match a particular pattern and they return same result. It can be demonstrated from the following example of ‘Student’ table.ExampleSuppose we want to search name, which contains ‘av’ in it, from ‘Student’ table. We can use INSTR() function ... Read More

How can we delete multiple rows from a MySQL table?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 20-Jun-2020 07:31:13

6K+ Views

We can use DELETE statement along with a WHERE clause, which identifies those multiple rows, to delete multiple rows from MySQL table.Examplemysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav   ... Read More

Java program to find the roots of a quadratic equation

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 19-Jun-2020 14:48:41

10K+ Views

Roots of a quadratic equation are determined by the following formula:$$x = \frac{-b\pm\sqrt[]{b^2-4ac}}{2a}$$To calculate the roots −Calculate the determinant value (b*b)-(4*a*c).If determinant is greater than 0 roots are [-b +squareroot(determinant)]/2*a and [-b -squareroot(determinant)]/2*a.If determinant is equal to 0 root value is (-b+Math.sqrt(d))/(2*a)Exampleimport java.util.Scanner; public class RootsOfQuadraticEquation {    public static ... Read More

What are the different ways to maintain data integrity in child table when the record is deleted in parent table?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 19-Jun-2020 13:26:49

245 Views

When two tables are connected with Foreign key and data in the parent table is deleted, for which record exists in child table too, then followings are the ways to maintain data integrity −On Delete CascadeThis option will remove the record from child table too if that value of the ... Read More

How can we remove NOT NULL constraint from a column of an existing MySQL table?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 19-Jun-2020 11:29:02

6K+ Views

We can remove a NOT NULL constraint from a column of an existing table by using the ALTER TABLE statement.ExampleSuppose we have a table ‘test123’ having a NOT NULL constraint on column ‘ID’ as follows −mysql> DESCRIBE test123; +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | ... Read More

How to Calculate the Area of a Triangle using Python?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 17-Jun-2020 12:42:15

959 Views

Calculating the area of a triangle is a formula that you can easily implement in python. If you have the base and height of the triangle, you can use the following code to get the area of the triangle, def get_area(base, height):    return 0.5 * base * height print(get_area(10, ... Read More

How to generate a sorted list in Python?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 17-Jun-2020 12:35:01

309 Views

The sort method on lists in python uses the given class's gt and lt operators to compare. Most built in classes already has these operators implemented so it automatically gives you sorted list. You can use it as follows:words = ["Hello", "World", "Foo", "Bar", "Nope"] numbers = [100, 12, 52, ... Read More

How do I run two python loops concurrently?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 17-Jun-2020 12:22:33

581 Views

You will need to use a multiprocessing library. You will need to spawn a new process and provide the code to it as an argument. For example, from multiprocessing import Processdef loop_a():    for i in range(5):       print("a") def loop_b():    for i in range(5):   ... Read More

How to write inline if statement for print in Python?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 17-Jun-2020 12:05:59

5K+ Views

Python provides two ways to write inline if statements. These are:1. if condition: statement2. s1 if condition else s2Note that second type of if cannot be used without an else. Now you can use these inline in a print statement as well. For example, a = True if a: print("Hello")This ... Read More

Previous 1 ... 6 7 8 9 10 ... 32 Next
Advertisements