goods_name 产品名字,
max(price) 价格,
max(case rank_name when 'VIP1' then (case when user_price is null then discount*price/100 else user_price end) end) vip1价格,
max(case rank_name when 'VIP2' then (case when user_price is null then discount*price/100 else user_price end) end) vip2价格,
max(case rank_name when 'VIP3' then (case when user_price is null then discount*price/100 else user_price end) end) vip3价格
from member_price mp
left join goods gd on gd.goods_id = mp.goods_id
left join user_rank ur on ur.rank_id = mp.rank_id
group by goods_name
mysql不是很熟悉,所以写了个标准sql语法的。我记得mysql中group by的select可以不用跟聚合函数的,所以LZ大概可以把max()去掉,而mysql中好像有isnull,ifnull的函数,我不太了解,这里用case语句替代了,LZ可以自行替换。
SELECTb.*
FROM
article
LEFT JOIN (
SELECT
@rownum :=@rownum + 1 AS rownum,
article.*
FROM
(SELECT @rownum := 0) r,
article
) b ON article.id = b.id
mysql没有rownum,只能这样进行计算
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)