Java program to print a given pattern. (stars)

venkata sai
Published on 12-Jul-2019 11:59:14
Following is a Java program which prints a pyramid of numbers.Example Live Demopublic class PrintingPyramidStars {    public static void main(String args[]){       int n, i, j;       n = 5;       for(i = 0; i<= n; i++) {          for(j = ... Read More

Java Programs for printing Pyramid Patterns. (of numbers)

venkata sai
Published on 12-Jul-2019 11:57:17
Following is a Java program which prints a pyramid of numbers.Example Live Demopublic class PrintingPyramids {    public static void main(String args[]){       int n, i, j, k=1;       n = 5;       for(i = 0; i<= n; i++) {          for(j ... Read More

Java Program to find all angles of a triangle

venkata sai
Published on 12-Jul-2019 11:52:13
To find the angles of a triangle we can use sin/cosine rules according to cosine rule −cos A = (b^2 + c^2 - a^2)/2bcwhere A, B , C are the vertices and a, b, c are the sides of the given triangle then, angles of the triangle when the sides ... Read More

How to update multiple rows and left pad values in MySQL?

Sharon Christine
Published on 12-Jul-2019 11:43:18
Use the LPAD() function to left pad values. Let us first create a table −mysql> create table DemoTable    -> (    -> Number int    -> ); Query OK, 0 rows affected (2.26 secInsert some records in the table using insert command −mysql> insert into DemoTable values(857786); Query OK, ... Read More

How to search a MySQL table for a specific string?

Sharon Christine
Published on 12-Jul-2019 11:40:51
Use equal to operator for an exact match −select *from yourTableName where yourColumnName=yourValue;Let us first create a table −mysql> create table DemoTable -> ( -> FirstName varchar(100), -> LastName varchar(100) -> ); Query OK, 0 rows affected (0.70 secInsert some records in the table using insert command −mysql> insert into ... Read More

Can we combine MySQL IN AND LIKE operators?

Sharon Christine
Published on 12-Jul-2019 11:35:54
Yes, we can combine IN and LIKE operators in MySQL using LIKE and OR operator. Let us first create a table −mysql> create table DemoTable -> ( -> SubjectTitle text -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Selecting data from a MySQL table based on a specific month?

Sharon Christine
Published on 12-Jul-2019 11:33:10
Use the MONTH() method in MySQL to select date based on month. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(10), -> UserPostMessageDate datetime, -> UserLikes int -> ); Query OK, 0 rows affected (0.77 sec)Insert ... Read More

Calling NOW() function to fetch current date records in MySQL?

karthikeya Boyini
Published on 12-Jul-2019 11:30:12
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 (1.16 sec)Insert some records in the table using insert command. Consider current date “2019-06-28” −mysql> insert into DemoTable(ShippingDate) values('2019-01-31'); Query ... Read More

MySQL query to conduct a basic search for a specific last name in a column

karthikeya Boyini
Published on 12-Jul-2019 11:27:01
You can use LIKE operator to conduct a basic search for last name. Let us first create a table: −mysql> create table DemoTable    -> (    -> CustomerName varchar(100),    -> CustomerAge int    -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using ... Read More

What is the usage of zerofill in a MySQL field?

karthikeya Boyini
Published on 12-Jul-2019 11:25:03
Zerofill pads the displayed value of the field with zeros up to the display width specified in the column definition. For example, if column is set int(8), therefore the width is 8. If the number is let’s say 4376, then zero will be padded on the left for total width ... Read More
Advertisements