select m.name,m.merchant_id,c.*
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text'这样查出来是 多条数据! 如何取出 m.merchant_id 最大的那条记录
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text'这样查出来是 多条数据! 如何取出 m.merchant_id 最大的那条记录
select m.name,m.merchant_id,c.*
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text')
select * from t where merchant_id=(select max(merchant_id) from t);
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text' AND ROWNUM = 1
ORDER BY m.merchant_id DESC
select rownum,t.* from
(select m.name,m.merchant_id,c.*
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text'
order by m.merchant_id desc) t
where rownum=1;
没数据就没试,不知道行不行,你试试
select id from user_city where rownum=1 order by id desc;