SELECT Max(c.vendor_id),c.vendors_id FROM (SELECT distinct a.vendor_id FROM service_master a,products b,vendors v,`vendor_addresses` ad WHERE a.cat_id= 242 AND a.service_id = b.s_sid AND a.is_active =1 AND b.isproductactive = 1 AND v.vendorid = a.vendor_id AND ad.vendorchild_id = a.vendor_id AND v.isvendoractive = 1 LIMIT 10) c ORDER BY c.vendor_id
问题: 1)我想在vendor_id列中获得完整结果 2)Max(vendor_id)结果
如何在单个查询中获得结果?
答案 0 :(得分:0)
未经测试。但请试试这个。
select t1.id,t2.id
from detail t1
left join(
select max(id) as id
from detail
) t2 on 1 = 1
答案 1 :(得分:0)
select id, ( select max(id) from detail internal_detail
where detail.id = internal_detail.id ) as max from detail