根据下面的查询,您可以看到查询只返回匹配的行,但我想从USERS表中检索所有行并null代替不匹配的行。
select
u.*,
p.p_title,
DATE_FORMAT(max(trans.expiry), '%d-%m-%Y %H:%i:%s') as expiry_date,cn.cell_num
from (
select t.e_date as expiry
from connections c, trans_tbl t,users u
where c.v_lan_id=t.vlanconfk and u.u_id = t.u_id_fk
) AS trans,
users u INNER JOIN connections c on u.u_id=c.u_id_fk
INNER JOIN packages p on c.pkg_id_fk=p.pkg_id
INNER JOIN cell_num cn on u.u_id=cn.u_id_fk
牛魔王的故事