Wednesday, May 13, 2009

creditcard tips

lksanzlcw kmn

Wednesday, June 04, 2008

selecting duplicate rows in atable

I have a table of city names and need to find duplicate entries. The table does not have a primary key, so the duplicate rows are entirely identical.

Answer:

select city_name, count(city_name) as cnt from areas group by city_name where cnt>1

Thursday, March 22, 2007

Something Funny

http://www.scribd.com/doc/13408/What-People-say-in-Court

Sunday, March 11, 2007

Runtime Polymorphism

class A extends Object{
public void m(){
System.out.println("m in class A");
}
}


class B extends A{
public void m(){
System.out.println("m in class B");
}
}


public class Runtime{
public static void main(
String[] args){
A a = new A();
B b = new B();
a = b;
b.m(); //method in subclass is called
}
}

Tuesday, March 06, 2007

jdbc with mysql

/**
*
*/
package mysql;
import java.sql.*;

/**
* @author princeteja *
*/
public class Main {

/**
* @param args
*/
public static void main(String[] args) {

try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/menagerie","root", "database" );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from pet");
while(rs.next()){
System.out.println(rs.getString(1));
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
st.close();
con.close();
}


}

}

Tuesday, January 23, 2007

Hiding the address bar using javascript


function openWindow(){
window.open‘filename.htm’,‘null’,‘width=200,height=250,toolbar=no,scrollbars=no,location=no,resizable=yes’);
window.moveTo(0,0);
window.resizeTo(screen.width,screen.height);
window.close();}

Thursday, January 11, 2007

Normalization

http://www.utexas.edu/its/windows/database/datamodeling/rm/rm7.html

Print the max n sals in MySql;

select sal from emp order by sal desc limit n

nth max salary in MySql

select max(sal) fom emp a where (n-1)=(select count(sal) from emp e where a.sal >= e.sal)