Skip to content Skip to sidebar Skip to footer

Get Min Id And Max Id Value In Mysql Php

I wonder how to get the timeIn which has the min id and timeOut which has the max id from MySQL php to android ? This is table work_Details(id,project,percentage,timeIn,timeOut,twd

Solution 1:

retrieves the timeIn and timeOut which has the max id...

Do it as to get MiNtimeIn from First JSONObject and MaXtimeOut from second JSONObject:

StringMiNtimeIn,MaXtimeOut;
JSONArray array=newJSONArray(json);
if(array.length()<2){
  JSONObject jsonObject = array.getJSONObject(0);
  MiNtimeIn = jsonObject.optString(Configs.TAG_IN);
  MaXtimeOut=jsonObject.optString(Configs.TAG_OUT);
}else{
  // get First Object from JSONArrayJSONObject oneObject = array.getJSONObject(0);
  MiNtimeIn = oneObject.optString(Configs.TAG_IN); // get min from first row// get Second Object from JSONArrayJSONObject twoObject = array.getJSONObject(array.length()-1);
   MaXtimeOut = twoObject.optString(Configs.TAG_OUT); // get min from second row
}

Post a Comment for "Get Min Id And Max Id Value In Mysql Php"