
I have doubt in Where clause .. i got a Employid from user and check the id and display the details of that id what can i do?

The WHERE clause is used to filter records.It is used to extract only those records that fulfill a specified criterion.
SQL WHERE Syntax:
SELECT column_name(s) FROM table_name WHERE column_name = value;
Example:
In the given example, we have accepted the id from the user and retrieve the record of that user from the database.
import java.sql.*;
import java.util.*;
class RetrieveData
{
public static void main(String[] args) throws Exception
{
Scanner input=new Scanner(System.in);
System.out.print("Enter id: ");
int id=input.nextInt();
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from data where id="+id+"");
while(rs.next()){
String name=rs.getString("name");
String address=rs.getString("address");
String contact=rs.getString("contactNo");
String email=rs.getString("email");
System.out.println(name+" \t "+address+" \t "+contact+" \t "+email);
}
}
}