gpt4 book ai didi

php - 如何选择字段数组在一行中显示或在一行中显示json

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

select 
s.id,
s.name,
c.PNAME city,
s.user_name,
s.logo,
sqrt(pow((latitude-'1'),2)+pow((longitude-'1'),2)) as distance ,
(SELECT
ph.phone_number
FROM `phones` as ph
WHERE (ph.type='tel' AND ph.`shop_id`=s.id)) as phons
from shops as s
JOIN addresses as a ON s.address_id=a.id
JOIN city as c ON c.id=a.city
where 1
order by('distance ASC')
limit 0,20 ;

上面的代码给我一个错误:

Error code 1242, SQL state 21000: Subquery returns more than 1 row

最佳答案

    select s.id,s.name,
c.PNAME city,s.user_name,s.logo,
sqrt(pow((latitude-'1'),2)+pow((longitude-'1'),2)) as distance ,
((SELECT GROUP_CONCAT(ph.phone_number) FROM `phones` as ph WHERE (ph.type='tel'))) as phons
from shops as s
JOIN addresses as a ON s.address_id=a.id
JOIN city as c ON c.id=a.city
where 1
order by('distance ASC')
limit 0,20 ;

GROUP_CONCAT reult numberphone in row

关于php - 如何选择字段数组在一行中显示或在一行中显示json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31536441/

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