la consulta es la siguiente:
Código PHP:
$query2= "select A.ID_email ,
A.FECHA ,
A.TEMA ,
A.TO_ ,
A.TO_OTHER ,
A.TO_NAME_OTHER ,
A.FROM_ ,
A.FROM_NAME ,
A.FECHA_REG ,
A.ASIGNACION ,
A.BODY,
A.ENVIADO,
A.ID_EMPRESA,
A.CC,
A.CO,
A.LEIDO,
A.USUR_LEIDO
from correo_electronico A, EMAIL_CARPETA B, CARPETAS C
where NOT EXISTS (select B.ID_EMAIL
from EMAIL_CARPETA B, CARPETAS C
)
$add and (A.TO_ LIKE '%$usu%' || A.CC LIKE '%$usu%' || A.CO LIKE '%$usu%')
AND B.ID_EMAIL=A.ID_email
AND C.ID=B.ID_CARPETA
AND C.ID_USUARIO='".$_SESSION['ID_TRA']."'
ORDER BY $ORDEN1 limit " . $inicio . "," . $TAMANO_PAGINA;