Mi consulta es la siguiente...
Código PHP:
$dns="ACU";
$conexion = odbc_connect("$dns","","","");
$strqry = "select a.PIN, a.ACCESS_DATE, a.TYPE, a.ACU_NUMBER, u.USER_CODE, u.USERS_GROUP_ID, u.FIRST_NAME, u.LAST_NAME FROM access a INNER JOIN users u ON u.USER_CODE = a.PIN where 1 = 1";
if ($fecha_desde !=="" and $fecha_hasta !==""){
$strqry.= "AND a.ACCESS_DATE BETWEEN '$inicio' AND '$fin'";
}
if ($user_id !=="Apellido y Nombre") {
$strqry.= " AND a.PIN='$user_id'";
}
$strqry.= " ORDER BY u.LAST_NAME ";
$consulta=odbc_exec($conexion,$strqry);
$registros=odbc_num_rows($consulta);