资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

怎么编写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语句
文章位置:http://cdkjz.cn/article/dogcodh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220