Back to Top

Saturday, 23 February 2013

SQL: WHERE Command

In SQL,when ever you want to SELECT some data, or UPDATE or DELETE some information from a Table, you needs to provide some condition, on basis of which operation will be performed. It's not necessary to SELECT, UPDATE or DELETE all data from a table or view. So, condition is necessary to filter the data when performing an operation on database. The basic structure of of WHERE conditions is :

  Syntax: SELECT [column_name] FROM [table_name] WHERE [condition]


Again, we will see the same table
Employee Details ( employee_details), which contains 
Employee ID ( emp_id), 

Employee Name (emp_name), 
Employee Address (emp_address) and
Employee Role: (emp_role).

Table:  employee_details 

Now, from this table, if a situation ariser, where we have to just select the information of the developers, the we have to set some condition on our SELECT query, so that we can get the details of the employees with 'emp_role' 'Developer' . Then the Query will be

SELECT * FROM employee_details WHERE emp_role = 'Developer';


In this way we can filter our data output.

Saturday, 23 February 2013 by Anijit Sarkar · 1 Read more »

Sunday, 17 February 2013


SELECT command is use in SQL to "SELECT [some info] FROM [a location]".  Now, this is the basic structure of the SELECT query, where SELECT and FROM are 2 commands of SQL. Here, [some info] part will be the column names separated by comma (,) sign and [a location] part will be the name of the Table or View. So, the syntax will be :

For Single Column :
Syntax : SELECT [Column_name] FROM [Table_Name];

For Multiple Columns :
Syntax : SELECT [Column1_name, Column2_name, Column3_name] FROM [Table_Name];

Now, what if you want to select all the columns of a table or a view. Do you have to write all the column name for that. No necessarily, you can user the star (*) sign in [Column_name] area. Then the syntax will be:

For All Columns :
Syntax : SELECT * FROM [Table_Name];

Suppose there is a table to keep
Employee Details (Table Name: employee_details), which contains
Employee ID(Column Name: emp_id), 

Employee Name(Column Name: emp_name), 
Employee Address:(Column Name: emp_address) and
Employee Role: (Column Name: emp_role).

Table:  employee_details 

 Now, to select emp_id and emp_name from the table, the query will be,

SELECT emp_id, emp_name FROM employee_details;


 Again, if you wants to select all the colunms' record, then the query will be,

 SELECT * FROM employee_details;



Sunday, 17 February 2013 by Anijit Sarkar · 2 Read more »

Friday, 15 February 2013

JAVA: Parse String to Double

Paser String to Double:

You can parse a double value in string format to double in 4 ways.

  1. Double.valueof(String s) :  This method returns a double object containing the value invoked in it in string format.
    • It can trim white-space in start or end of the string argument, by using String.trim().
    • It throws NumberFormatException if the string argument is not in proper form.
  2.  Double.parseDouble(String s) : This method also returns a double instance containing the invoked string value.
    • It can also trim white space in start and end of the input value, using String.trim().
    • It also throws NumberFormatException if the string argument is not in proper form.
  3. new Double(String paramString) : You a also parse a string argument containing float value by invoking it on the constructor of the Class Double. its internally using the valueof(String s) method and returns a new Double instance containing the parsed double value. So it is also using
    String.trim() and throws NumberFormatException.
  4. Fourth one, the last one is the very important one, actually its been used by all the above 3 APIs. sun.misc.FloatingDecimal.readJavaFormatString(String paramString). Its the original method used to parse a String value to decimal value. This is the actual methods, which is trimming the white space of the string, using String.trim(). It returns value in FloatingDecimal instance, so you need to cast it to double by using doubleValue(), which is another method of Class FloatingDecimal.
Below is an example which explains the above discussion:



public class PaserStringToDouble {

       * Sample class that shows how to parse a String to double.
       * @author
      public static void main(String[] args) {
            // TODO Auto-generated method stub

            // set a decimal value in a string with
            // white space on both end.
            String strValue = " 12.329 ";

            // parse the string to double using
            //Double.valueof(String s)
            double dblValue = Double.valueOf(strValue);

            // parse the string to double using
            // Double.parseDouble(String s)
            double dblValue2 = Double.parseDouble(strValue);

            // parse the string to double using
      //Double(String paramString)
            Double dblValue3 = new Double(strValue);

            // parse the string to double using new
            // FloatingDecimal.readJavaFormatString
            //(String paramString)
            Double dblValue4 = new Double(sun.misc.FloatingDecimal

            // printing the outputs
            System.out.println("dblValue: " + dblValue +
       "\ndblValue2: " + dblValue   + "\ndblValue3: " +
       dblValue3 + "\ndblValue4: " + dblValue4);



dblValue: 12.329
dblValue2: 12.329
dblValue3: 12.329
dblValue4: 12.329

Friday, 15 February 2013 by Anijit Sarkar · 1 Read more »

Thursday, 14 February 2013

SQL: What is SQL

  SQL (Structured Query Language) is a type of programming language, which uses to communicate with database. It’s also known as “sequel”. It provides some syntax which helps you to interact with a database. These syntax are very similar to normal English language, so it’s easy to remember and use. Now a day, all major RDBMS (Relational Database Management System)  like MySQL, Oracle, postgres, MS Access and SQL Server uses SQL to maintain data.

  SQL helps to store, manipulate, read and delete data from data base. It helps to performs the CRUD(Create, Read, Update & Delete) operations in RDBMS.

Create: It helps to create database, schema, table  and view, along with there properties.

Read: It helps to select all information from single or multiple records from one or many table or view.

Update: It also helps us to manipulates existing data in a database.

Delete: It can also delete information or structure of database or table.

Thursday, 14 February 2013 by Anijit Sarkar · 2 Read more »

Sunday, 10 February 2013

FRAMEWORK: MVC – Model View Controller

Model-View-Controller (MVC) is a popular Software Architecture pattern widely used in web applications. It separates application data from UI (user interface) by a thin controlling layer, which actually helps as a bridge between UIs and model. In this pattern the whole application is separated in 3 layers, 

1.       Models are answerable for encapsulating application data, for view to present the data.
2.       Views should only present this data, without involving any business logic.
3.       Controllers are answerable for receiving requests from users and invoking back-end services for business process.

Sunday, 10 February 2013 by Anijit Sarkar · 4 Read more »

Popular Posts

All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar
blog links Web Directory Academics Blogs