gpt4 book ai didi

mysql重命名结果?

转载 作者:行者123 更新时间:2023-11-29 07:10:29 25 4
gpt4 key购买 nike

我有这个功能

SELECT LEFT( eventName, INSTR( CONCAT( eventName, ':' ) , ':' ) ) AS prefix, COUNT( * )
FROM trackingevent
GROUP BY LEFT( eventName, INSTR( CONCAT( eventName, ':' ) , ':' ) )
UNION SELECT homeupload, COUNT( * )
FROM link
GROUP BY homeupload
UNION
SELECT mediaType, COUNT( * )
FROM link
GROUP BY mediaType
UNION
SELECT emailSub, COUNT(*) FROM link WHERE emailSub='1' GROUP BY emailSub

它会生成类似的东西

prefix  COUNT(*)
CONTEST_ENTRY: 4
EMAIL_SHARE 77
FLICKR_SHARE 9
SHARE_FACEBOOK 105
SHARE_STATION_LOGIN 223
TWEET_SHARE 18
0 320
1 1
image 320
video 1
1 195

我想将 0,1 和另一个 1 重命名为其他名称。也许是家庭上传、现场或其他方式。

前0和1是UNION SELECT homeupload, COUNT( * ) 来自链接 按首页上传分组

因为有两个值

第二个1是UNIONSELECT emailSub, COUNT(*) FROM link WHERE emailSub='1' GROUP BY emailSub

如何重命名结果?

最佳答案

简而言之,使用IF

...
UNION
SELECT IF(homeupload = 0,
"someStringDescribingStatus0",
"someStringDescribingStatus1") as homeUploadStatus,
count(*)
FROM ...

关于mysql重命名结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4812704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com