快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

怎么编写MYSQL语句 mysql怎么写sql语句

请问mysql语句怎么写?

select

我们提供的服务有:网站设计制作、成都网站建设、微信公众号开发、网站优化、网站认证、高阳ssl等。为上千企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的高阳网站制作公司

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可以自行替换。

mysql的sql语句怎么写?

这个是SQL SERVER的语法,MY SQL的思路应该是类似的

---------------------------------------------------------

select

*

from

(select

isnull(sum(online_count),0) h16

from

#a

where

datepart(hh,watch_time)=16) a,

(select

isnull(sum(online_count),0) h17

from

#a

where

datepart(hh,watch_time)=17) b,

(select

isnull(sum(online_count),0) h18

from

#a

where

datepart(hh,watch_time)=18) c,

(select

isnull(sum(online_count),0) h19

from

#a

where

datepart(hh,watch_time)=19) d

mysql 语句该如何写

最好是拆开来使用,比如数据里面有1,2,3 你要查询 1,3

就写find_in_set('1',ids) and find_in_set('2',ids);

如果你只是查询2

就直接 where find_in_set('2',ids);

如果是完全要相等 就直接写等于啊,如果只是需要包含就用上面的、


分享名称:怎么编写MYSQL语句 mysql怎么写sql语句
标题URL:http://6mz.cn/article/dogcodh.html

其他资讯