Statement st=conn.createStatement();
String sql="SELECT a.ID,a.A_TEXT,a.B_TEXT,a.C,a.D_TO_E,a.F_TEXT,a.G,a.INTIME,b.EXIT_TIME FROM tm_A a LEFT JOIN tm_B b ON a.ID=b.ID WHERE EXIT_TIME=''";
ResultSet rs=st.executeQuery(sql);
while(rs.next())
{
arls.add(rs.getString("ID"));
arls.add(rs.getString("A_TEXT"));
arls.add(rs.getString("B_TEXT"));
arls.add(rs.getString("C"));
arls.add(rs.getString("D_TO_E"));
arls.add(rs.getString("F_TEXT"));
arls.add(rs.getString("G"));
arls.add(rs.getString("INTIME"));
arls.add(rs.getString("EXIT_TIME"));
}
I have above code in that i want to retreive values from two tables where EXIT_TIME =’null’
but i am getting nothing after executing though there are value in table tm_A
but if i remove where clause then i am getting result and but under EXIT_TIME it displays ‘null’ and where there are values that are displaying
If you want to select a result where a column is
nullyou have to use theisoperator:Comparison with
nullwill always result tounknown. That is why you need theisoperator instead of=using
EXIT_TIME=''would compareEXIT_TIMEto an empty string but notnullIf you want all records that are not
nullinEXIT_TIMEyou can useEdit
You can use
caseto avoidnullin your textboxes: