I have two selects I'd like to combine:
$sql = "SELECT ";
$sql .= join(", ", array_keys($tbl_vars));
$sql .= " , a.u_id, MIN(m.ms_type) as msbestpriv, m.ms_id, m.ms_end ";
$sql.=" FROM $pg_dbtbl1 AS a
LEFT JOIN memship_duration AS m ON (m.u_id=a.u_id )
LEFT JOIN ctcr AS b ON (b.u_id=a.u_id )
WHERE m.agnt_id=0 GROUP BY m.u_id LIMIT $a ,$b"
and this
$tlsql="SELECT in_tdate FROM user_session WHERE u_id='$u_id' ORDER BY in_tdate DESC LIMIT 2";
which Id' add as
...LEFT JOIN user_session ON (user_session.u_id=a.u_id )
but there cant be any any way I can add the 'order by' and 'limit' to a left join, is there?
I need the first limit clause to be the governing one
I'm not sure its possible - any tips?
will sub-select do this?