Sharon Christine has Published 413 Articles

Retrieving MySQL Database structure information from Java?

Sharon Christine

Sharon Christine

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

467 Views

Use DatabaseMetaData class to retrieve MySQL database structure. In this example, we will display all the table names of database “web” using Java with the help of getMetaData().Following is the Java code −Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import com.mysql.jdbc.DatabaseMetaData; public class getDatabaseInformationDemo {    public static ... Read More

Add a new column and index to an existing table with ALTER in a single MySQL query?

Sharon Christine

Sharon Christine

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

436 Views

To add a new column to an existing table, use ADD. With that, to add a new index, use the ADD INDEX(). Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(100),    -> PRIMARY KEY(Id) ... Read More

How to find a value between range in MySQL?

Sharon Christine

Sharon Christine

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

681 Views

For this, use BETWEEN operator in MySQL. Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Start int,    -> End int    -> ); Query OK, 0 rows affected (0.91 sec)Insert some records in ... Read More

Why does MySQL evaluate “TRUE or TRUE and FALSE” to true?

Sharon Christine

Sharon Christine

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

232 Views

MySQL evaluates “TRUE or TRUE and FALSE” to true because AND has the highest priority than OR i.e. AND is evaluated before OR.The MySQL evaluates the above statement like this. The AND operator gets evaluated first −(TRUE or (TRUE AND FALSE))The statement (TRUE AND FALSE) gives the result FALSE. Then ... Read More

Get the count of duplicate values from a single column in MySQL?

Sharon Christine

Sharon Christine

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

223 Views

Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(20); Query OK, 1 row ... Read More

Can we use IN() to search between comma separated values within one field?

Sharon Christine

Sharon Christine

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

161 Views

Instead of IN(), use FIND_IN_SET to search between comma separated values within one field. Let us first create a table −mysql> create table DemoTable -> ( -> ListOfValues text -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in ... Read More

How to add NOT NULL constraint to an already created MySQL column?

Sharon Christine

Sharon Christine

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

295 Views

Achieve this using ALTER TABLE. Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(100)    -> ); Query OK, 0 rows affected (0.86 sec)Let us check the description of the table −mysql> desc ... Read More

Finding the minimum and maximum value from a string with numbers separated by hyphen in MySQL?

Sharon Christine

Sharon Christine

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

589 Views

Use MIN() function along with SUBSTRING() for minimum, whereas MAX() for maximum. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Value varchar(100) -> ); Query ... Read More

Can we implement 'LIKE' and ‘IN’ in a single MySQL query?

Sharon Christine

Sharon Christine

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

340 Views

For more efficiency, use Regular Expression for the same task. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(30) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert ... Read More

C Program for Program to find the area of a circle?

Sharon Christine

Sharon Christine

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

17K+ Views

The area is a quantity that represents the extent of the figure in two dimensions. The area of a circle is the area covered by the circle in a two dimensional plane.To find the area of a circle, the radius[r] or diameter[d](2* radius) is required.The formula used to calculate the ... Read More

Advertisements