mySQL查询语句行转列横向显示

mySQL查询语句行转列横向显示,第1张

我仅提供思路给你,至于其它单位,可以单独摘录出来,union all

select 始发地 目的地 起步价,sum(case when 区间 >0 and 区间 <= 20 then 单位价格 else '' end) '0-20(公斤)' ,

sum(case when 区间 >20 and 区间 <= 50 then 单位价格 else '' end) '20-50(公斤)' ,

sum(case when 区间 >50 and 区间 <= 100 then 单位价格 else '' end) '50-100(公斤)' from (你的sql语句) t group by t.始发地 ,t.目的地 ,t.起步价

$username = 'dabao0120'

res = mysql_query(&my_connection, "SELECT

username, password FROM user WHERE username = '$username'")

能看明白吗?这是php的写法 你要注意的就是 查询语句字段为字符型的时候 需要用引号引起来


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7380342.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存