gpt4 book ai didi

mysql - 从表中选择值,ID 在一列中

转载 作者:行者123 更新时间:2023-11-28 23:29:50 26 4
gpt4 key购买 nike

我有这个 MySQL 查询,效果很好,我只需要为 properties.advantages. 中的每个 ID 获取 advantages.value。如图所示, Advantages 列设置得很奇怪(至少对我来说,我没有创建它)并且 ID 由 - 分隔。我怎样才能获得这些值?

SELECT 
properties.id,
(SELECT types.value FROM types WHERE types.id = properties.type_id) as types,
properties.price,
properties.town_id,

**( SELECT advantages......),**

towns.id,
towns.value
FROM properties
LEFT JOIN towns
ON properties.town_id=towns.id
WHERE properties.published='1'

enter image description here enter image description here

最佳答案

我猜这是您遇到问题的线路?

**( SELECT advantages......),**

您可以使用 LIKECONCAT() 来比较它们:

SELECT a.advantagesCol FROM advantages a
WHERE CONCAT('-',properties.id,'-') LIKE a.Id_Column

关于mysql - 从表中选择值,ID 在一列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37696488/

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