gpt4 book ai didi

mysql - 获取一行中 2 行值的结果

转载 作者:行者123 更新时间:2023-11-29 17:20:20 24 4
gpt4 key购买 nike

连接查询的结果 -

SELECT st_stock.name, st_stock.price, 
FORMAT(st_stock.quantity,0),
st_stock.exp_date,
admin.username
FROM `st_stock`
INNER JOIN `admin` ON FIND_IN_SET(admin.ID,st_stock.broker_id) AND st_stock.id='2'

示例数据

name        price     asjdb       exp_date            username
5.HK (HSBC) 74.40 HKD 100,000,000 2018-07-27 17:00:00 broker2
5.HK (HSBC) 74.40 HKD 100,000,000 2018-07-27 17:00:00 broker3

预期输出

 5.HK (HSBC) 74.40 HKD 100,000,000 2018-07-27 17:00:00 broker2,broker3

最佳答案

如果这是sql,

 SELECT st_stock.name, st_stock.price, 
FORMAT(st_stock.quantity,0),
st_stock.exp_date,
GROUP_CONCAT(admin.username)
FROM `st_stock`
INNER JOIN `admin` ON FIND_IN_SET(admin.ID,st_stock.broker_id) AND st_stock.id='2' GROUP BY st_stock.name

关于mysql - 获取一行中 2 行值的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51286468/

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